Commit 4c32ac2b authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Implemented random sorting

parent b16179c5
from flask.ext.login import UserMixin
from datetime import datetime
import random
from shared import db
......@@ -100,6 +101,8 @@ class Topic(db.Model):
return sorted(statements, key=lambda st:-2 if st.is_current else -1 if st.is_meta else st.id)
elif self.mode == "balanced":
return sorted(statements, key=lambda st:-2 if st.is_current else -1 if st.is_meta else st.speaker.count(self))
elif self.mode == "random":
return sorted(statements, key=lambda st:random.random())
else:
return statements
......
......@@ -37,5 +37,5 @@ class NewEventForm(Form):
class NewTopicForm(Form):
name = StringField("Name", validators=[InputRequired("Entering the name is required.")])
mode = StringField("Mode", validators=[InputRequired("Entering the mode is required."), AnyOf(values=["balanced", "fifo"], message="Must be 'balanced' or 'fifo' atm.")])
mode = StringField("Mode", validators=[InputRequired("Entering the mode is required."), AnyOf(values=["balanced", "fifo", "random"], message="Must be 'balanced', 'fifo' or 'random' atm.")])
event_id = HiddenField("Event_id")
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