Commit b68bb8b1 authored by Romain Bignon's avatar Romain Bignon

add 'maybe' state in events

parent 58ea35ab
......@@ -39,10 +39,12 @@ __all__ = ['EventsPlugin']
class Event(object):
(USER_CONFIRMED,
USER_MAYBE,
USER_WAITING,
USER_DECLINED) = range(3)
USER_DECLINED) = range(4)
STATES = {'x': USER_CONFIRMED,
'?': USER_MAYBE,
' ': USER_WAITING,
'-': USER_DECLINED
}
......@@ -118,7 +120,7 @@ class Event(object):
fp.write('Place:\n')
fp.write('%s\n\n' % binary(self.place))
fp.write('Attendees:\n')
stats = [0, 0, 0]
stats = [0, 0, 0, 0]
for username, state in sorted(self.users.items(), key=lambda (k, v): (v, k)):
realname = self.get_user(username).realname
checked = self.get_sign(state)
......@@ -342,7 +344,11 @@ class EventAction(ViewAction):
self.get(Event.USER_DECLINED)
def put(self):
self.get(Event.USER_CONFIRMED)
state = self.ctx.req.POST.get('_state')
if state == 'maybe':
self.get(Event.USER_MAYBE)
else:
self.get(Event.USER_CONFIRMED)
class EventsCleaner(ICleaner):
......
......@@ -14,6 +14,10 @@ form.accept button {
color: green;
}
form.maybe button {
color: #FFA806;
}
form.decline button {
color: red;
}
......
......@@ -3,6 +3,7 @@
<%
event_classes = {
event.USER_WAITING: 'waiting',
event.USER_MAYBE: 'maybe',
event.USER_CONFIRMED: 'confirmed',
event.USER_DECLINED: 'declined',
}
......@@ -24,7 +25,7 @@ event_classes = {
<section>
<h3>Date</h3>
<p><time datetime="${event.date.strftime('%Y-%m-%dT%H:%M') | h}">${event.date.strftime('%Y-%m-%d %H:%M') | h}</time></p>
<p><time datetime="${event.date.strftime('%Y-%m-%dT%H:%M') | h}">${event.date.strftime('%A %d %B %Y, %H:%M') | h}</time></p>
</section>
<section>
......@@ -53,6 +54,8 @@ event_classes = {
<strong>waiting</strong>.
% elif user_state == event.USER_CONFIRMED:
<strong>confirmed</strong>.
% elif user_state == event.USER_MAYBE:
<strong>maybe</strong>.
% elif user_state == event.USER_DECLINED:
<strong>declined</strong>.
% endif
......@@ -60,9 +63,17 @@ event_classes = {
% if user_state != event.USER_CONFIRMED:
<form class="change-status accept" method="post" action="${url | n,U,h}">
<input name="_method" type="hidden" value="PUT" />
<input name="_state" type="hidden" value="confirm" />
<button type="submit">Confirm</button>
</form>
% endif
% if user_state != event.USER_MAYBE:
<form class="change-status maybe" method="post" action="${url | n,U,h}">
<input name="_method" type="hidden" value="PUT" />
<input name="_state" type="hidden" value="maybe" />
<button type="submit">Maybe</button>
</form>
% endif
% if user_state != event.USER_DECLINED:
<form class="change-status decline" method="post" action="${url | n,U,h}">
<input name="_method" type="hidden" value="DELETE" />
......
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