Commits

Justin Venezuela committed 7d7d071 Draft

More alert messages

Comments (0)

Files changed (4)

handlers/admin.py

 class Admin(ChessClubHandler):
   def get(self):
     if self.logged_in_member is None:
+      self.add_error('Please log in.')
       self.redirect('/login')
       return
     if not self.logged_in_member.officer:
+      self.add_error(('\'%s\' is not marked as an offcer account. Please '
+          + 'contact us if you think this is a mistake.')
+          % self.logged_in_member.email)
       self.redirect('/')
+      return
     self.context['meeting'] = database.get_meeting_information()
     self.context['members'] = database.get_all_members()
     self.render('admin.html')
 class AdminMeeting(ChessClubHandler):
   def post(self):
     if self.logged_in_member is None:
+      self.add_error('Please log in.')
       self.redirect('/login')
       return
     if not self.logged_in_member.officer:
+      self.add_error(('\'%s\' is not marked as an offcer account. Please '
+          + 'contact us if you think this is a mistake.')
+          % self.logged_in_member.email)
       self.redirect('/')
+      return
     description = self.request.get('meeting')
     if not description:
-      print 'Please fill in all fields.'
+      self.add_error('Please fill in all fields.')
+      self.redirect('/admin')
       return
     database.set_meeting_information(description)
+    self.add_success('Successfully changed meeting description.')
     self.redirect('/admin')
 
-class AdminOfficer(ChessClubHandler):
-  def post(self):
-    pass
-
 if __name__ == '__main__':
   app = WSGIApplication([
       ('/admin', Admin),
-      ('/admin/meeting', AdminMeeting),
-      ('/admin/officer', AdminOfficer)], debug = True)
+      ('/admin/meeting', AdminMeeting)], debug = True)
   run_wsgi_app(app)

handlers/login.py

 class Login(ChessClubHandler):
   def get(self):
     if self.logged_in_member is not None:
+      self.add_error('You\'re already logged in, %s!'
+          % self.logged_in_member.name)
       self.redirect('/')
       return
     self.render('login.html')
   def post(self):
     if self.logged_in_member is not None:
       self.add_error('You\'re already logged in, %s!'
-        % self.logged_in_member.name)
+          % self.logged_in_member.name)
       self.redirect('/')
       return
     name = self.request.get('register_name')

handlers/logout.py

 
 class Logout(ChessClubHandler):
   def get(self):
+    if self.logged_in_member is None:
+      self.add_error('You\'re not logged in.')
+    else:
+      self.add_success('Goodbye, %s!' % self.logged_in_member.name)
     session.log_out_member()
     self.redirect('/')
 

handlers/members.py

 class Members(ChessClubHandler):
   def get(self):
     if self.logged_in_member is None:
+      self.add_error('Please log in.')
       self.redirect('/login')
       return
     self.context['members'] = database.get_all_members()
 class MembersUpdate(ChessClubHandler):
   def post(self):
     if self.logged_in_member is None:
+      self.add_error('Please log in.')
       self.redirect('/login')
       return
     bio = self.request.get('bio')
     if not bio:
-      print 'Please fill in all fields.'
+      self.add_error('Please fill in all fields.')
+      self.redirect('/members')
       return
     database.set_bio(self.logged_in_member.email, bio)
+    self.add_success('Successfully changed biography.')
     self.redirect('/members')
 
 if __name__ == '__main__':