Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MilderJoghurt
rlf-server
Commits
3e32cd0e
Commit
3e32cd0e
authored
Jun 27, 2015
by
Fjen Undso
Browse files
fix vote and questionanswer deletion
parent
0ecb019f
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/VoteController.java
View file @
3e32cd0e
...
...
@@ -47,13 +47,13 @@ public class VoteController extends Controller {
// session owner has the power to reset all
for
(
Vote
v
:
session
.
votes
)
{
if
(
v
.
type
==
Vote
.
Type
.
REQUEST
&&
v
.
owner
==
vote
.
owner
||
vote
.
owner
==
session
.
owner
)
{
v
.
delete
(
);
session
.
delete
Vote
(
v
);
}
}
}
else
{
session
.
addVote
(
inserted
);
session
.
save
();
}
session
.
save
();
return
created
(
Json
.
toJson
(
inserted
));
// 201
}
else
{
return
badRequest
(
"owner missing"
);
// 400
...
...
app/models/Session.java
View file @
3e32cd0e
...
...
@@ -42,7 +42,6 @@ public class Session extends Model {
@JsonIgnore
@OneToMany
(
mappedBy
=
"session"
,
cascade
=
CascadeType
.
ALL
)
@Column
(
nullable
=
true
)
public
List
<
Vote
>
votes
=
new
ArrayList
<
Vote
>();
@Formats
.
DateTime
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
@@ -86,6 +85,12 @@ public class Session extends Model {
for
(
QuestionAnswer
a
:
this
.
questionAnswers
)
{
a
.
delete
();
}
this
.
questionAnswers
.
clear
();
}
public
void
deleteVote
(
Vote
v
)
{
v
.
delete
();
this
.
votes
.
remove
(
v
);
}
public
void
addVote
(
Vote
v
)
{
...
...
app/models/Vote.java
View file @
3e32cd0e
...
...
@@ -8,13 +8,13 @@ import javax.persistence.Entity;
import
javax.persistence.Id
;
import
javax.persistence.ManyToOne
;
import
com.avaje.ebean.annotation.EnumValue
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
play.data.format.Formats
;
import
play.data.validation.Constraints
;
import
play.db.ebean.Model
;
import
com.avaje.ebean.annotation.EnumValue
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
@Entity
public
class
Vote
extends
Model
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment