Commit 07086009 authored by Tom Käsler's avatar Tom Käsler

Merge branch 'keep-mods-on-room-update' into 'master'

Keep moderators when a full room update is done

Closes #59

See merge request arsnova/arsnova-backend!183
parents 132b9a9f 94dae93c
......@@ -396,6 +396,7 @@ public class Room extends Entity {
private String description;
private boolean closed;
private Set<Moderator> moderators;
private boolean moderatorsInitialized;
private Settings settings;
private Author author;
private PoolProperties poolProperties;
......@@ -475,6 +476,11 @@ public class Room extends Entity {
@JsonView(View.Persistence.class)
public void setModerators(final Set<Moderator> moderators) {
this.moderators = moderators;
moderatorsInitialized = true;
}
public boolean isModeratorsInitialized() {
return moderatorsInitialized;
}
@JsonView({View.Persistence.class, View.Public.class})
......
......@@ -45,6 +45,7 @@ import org.springframework.validation.Validator;
import de.thm.arsnova.connector.client.ConnectorClient;
import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.event.BeforeDeletionEvent;
import de.thm.arsnova.event.BeforeFullUpdateEvent;
import de.thm.arsnova.event.FlipFlashcardsEvent;
import de.thm.arsnova.model.Room;
import de.thm.arsnova.model.UserProfile;
......@@ -152,6 +153,13 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R
this.connectorClient = connectorClient;
}
@EventListener
public void handleRoomUpdate(final BeforeFullUpdateEvent<Room> event) {
if (!event.getEntity().isModeratorsInitialized()) {
event.getEntity().setModerators(event.getOldEntity().getModerators());
}
}
@EventListener
@Secured({"ROLE_USER", "RUN_AS_SYSTEM"})
public void handleUserDeletion(final BeforeDeletionEvent<UserProfile> event) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment