Permalink
Browse files

added unstaff event, including email notification if event becomes un…

…derstaffed
  • Loading branch information...
1 parent 8414350 commit 72849c2900cada10b3addae5166895502655b752 @billsaysthis billsaysthis committed Jun 23, 2010
Showing with 44 additions and 2 deletions.
  1. +6 −0 main.py
  2. +9 −2 models.py
  3. +28 −0 notices.py
  4. +1 −0 templates/event.html
View
@@ -56,6 +56,7 @@ def get(self, id):
is_staff = username(user) in dojo('/groups/staff')
can_approve = (event.status in ['pending'] and is_admin)
can_staff = (event.status in ['pending', 'understaffed', 'approved'] and is_staff and not user in event.staff)
+ can_unstaff = (not event.status in ['canceled', 'deleted'] and is_staff and user in event.staff)
logout_url = users.create_logout_url('/')
else:
login_url = users.create_login_url('/')
@@ -74,6 +75,11 @@ def post(self, id):
event.approve()
if state.lower() == 'staff' and is_staff:
event.add_staff(user)
+ if state.lower() == 'unstaff' and is_staff:
+ event.remove_staff(user)
+ # send notification is state changed to understaffed
+ if event.status == 'understaffed':
+ notify_unapproved_unstaff_event(event)
if state.lower() == 'cancel' and is_admin:
event.cancel()
if state.lower() == 'delete' and is_admin:
View
@@ -81,7 +81,7 @@ def staff_needed(self):
def is_approved(self):
'''Has the events team approved the event? Note: This does not
necessarily imply that the event is in state 'approved'.'''
- return self.status in ('understaffed', 'approved', 'cancelled')
+ return self.status in ('understaffed', 'approved', 'canceled')
def is_canceled(self):
return self.status == 'canceled'
@@ -110,7 +110,7 @@ def cancel(self):
user = users.get_current_user()
self.status = 'canceled'
self.put()
- logging.info('%s cancelled %s' % (user.nickname, self.name))
+ logging.info('%s canceled %s' % (user.nickname, self.name))
def delete(self):
user = users.get_current_user()
@@ -138,6 +138,13 @@ def add_staff(self, user):
self.put()
logging.info('%s staffed %s' % (user.nickname, self.name))
+ def remove_staff(self, user):
+ self.staff.remove(user)
+ if not self.is_staffed() and self.status == 'approved':
+ self.status = 'understaffed'
+ self.put()
+ logging.info('%s staffed %s' % (user.nickname, self.name))
+
def to_ical(self):
event = CalendarEvent()
event.add('summary', self.name if self.status == 'approved' else self.name + ' (%s)' % self.status.upper())
View
@@ -40,6 +40,34 @@ def notify_staff_needed(event):
Without your help, this event won't happen. If you can staff this event, click
the Staff button once logged in on this page:
+http://events.hackerdojo.com/event/%s-%s
+""" % (
+ event.member.email(),
+ event.estimated_size,
+ event.name,
+ event.start_time.strftime('%I:%M%p'),
+ event.end_time.strftime('%I:%M%p'),
+ event.start_time.strftime('%A, %B %d'),
+ event.estimated_size,
+ event.staff_needed(),
+ event.key().id(),
+ slugify(event.name),))
+
+def notify_unapproved_unstaff_event(event):
+ mail.send_mail(sender=FROM_ADDRESS, to=STAFF_ADDRESS,
+ subject="[Event Unapproved, Needs Staffing] %s on %s" % (event.name, event.start_time.strftime('%a %b %d')),
+ body="""Hello staff!
+
+Unfortunately a staffer can no longer support %s's ~%s person event.
+
+Event Name: %s
+at %s to %s on %s
+
+At %s people expected, %s staff members need to opt in to support this event.
+
+Without your help, this event won't happen. If you can staff this event, click
+the Staff button once logged in on this page:
+
http://events.hackerdojo.com/event/%s-%s
""" % (
event.member.email(),
View
@@ -16,6 +16,7 @@ <h3>{{event.name|title}}</h3>
{% if is_admin %}<input type="submit" name="state" value="Cancel" />{% endif %}
{% if is_admin %}<input type="submit" name="state" value="Delete" />{% endif %}
{% if can_staff %}<input type="submit" name="state" value="Staff" />{% endif %}
+ {% if can_unstaff %}<input type="submit" name="state" value="Unstaff" />{% endif %}
{% endif %}
</form>
</p>{% endif %}

0 comments on commit 72849c2

Please sign in to comment.