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
3cfc55be
Commit
3cfc55be
authored
Jun 28, 2015
by
Fjen Undso
Browse files
AnswerController: fix deletion of questionanswers
parent
02bacc6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/controllers/QuestionController.java
View file @
3cfc55be
package
controllers
;
import
java.util.ArrayList
;
import
java.util.List
;
import
models.QuestionAnswer
;
...
...
@@ -38,10 +39,11 @@ public class QuestionController extends Controller {
QuestionAnswer
answer
=
Json
.
fromJson
(
json
,
QuestionAnswer
.
class
);
if
(!
answer
.
owner
.
isEmpty
())
{
// Delete old answer(s) from same owner
List
<
QuestionAnswer
>
oldAnswers
=
QuestionAnswer
.
findFromOwner
(
answer
.
owner
);
List
<
QuestionAnswer
>
oldAnswers
=
new
ArrayList
<
QuestionAnswer
>(
session
.
questionAnswers
);
for
(
QuestionAnswer
qa
:
oldAnswers
)
{
qa
.
delete
();
if
(
qa
.
owner
.
equals
(
answer
.
owner
))
{
session
.
deleteAnswer
(
qa
);
}
}
QuestionAnswer
inserted
=
new
QuestionAnswer
(
session
,
answer
.
owner
,
...
...
app/models/Session.java
View file @
3cfc55be
...
...
@@ -93,6 +93,11 @@ public class Session extends Model {
v
.
delete
();
}
public
void
deleteAnswer
(
QuestionAnswer
q
)
{
this
.
questionAnswers
.
remove
(
q
);
q
.
delete
();
}
public
void
addVote
(
Vote
v
)
{
this
.
votes
.
add
(
v
);
}
...
...
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