1. Charlie Meyer
  2. CS242Registration

Commits

cemeyer2  committed 54e786b

started work on controllers

  • Participants
  • Parent commits 1d21623
  • Branches default

Comments (0)

Files changed (9)

File CS242Registration/cs242registration/controllers/admin.py

View file
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from cs242registration.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class AdminController(BaseController):
+
+    def index(self):
+        # Return a rendered template
+        #return render('/admin.mako')
+        # or, return a response
+        return 'Hello World'

File CS242Registration/cs242registration/controllers/moderator.py

View file
 class ModeratorController(BaseController):
 
     def index(self):
-        # Return a rendered template
-        #return render('/moderator.mako')
-        # or, return a response
-        return 'Hello World'
+        moderator = session['user']
+        sections = moderator.sections
+        c.moderator = moderator
+        c.sections = sections
+        return render('/derived/moderator/index.html')

File CS242Registration/cs242registration/controllers/student.py

View file
 from pylons.controllers.util import abort, redirect_to
 
 from cs242registration.lib.base import BaseController, render
+from cs242registration.model import Section
+from cs242registration import model as model
 
 log = logging.getLogger(__name__)
 
 class StudentController(BaseController):
 
     def index(self):
-        # Return a rendered template
-        #return render('/student.mako')
-        # or, return a response
-        return 'Hello World'
+        student = session['user']
+        section = student.section
+        c.student = student
+        c.section = section
+        return render('/derived/student/index.html')
+    
+    def register(self, id):
+        student = session['user']
+        new_section = h.get_object_or_404(Section, id=id)
+        if student.section is not None:
+            old_section = student.section
+            student.section = None
+            #old_section.students.remove(student)
+        student.section = new_section
+        model.Session.commit()
+        redirect_to(controller='student', action='index')

File CS242Registration/cs242registration/model/__init__.py

View file
 """The application's model objects"""
 import elixir
 from cs242registration.model import meta
-from cs242registration.model.model import *
 
 Session = elixir.session = meta.Session
 # Uncomment if using reflected tables
     elixir.delay_setup = True
 
 # # import other entities here, e.g.
-# from cs242registration.model.blog import BlogEntry, BlogComment
+# from mossweb.model.blog import BlogEntry, BlogComment
+
+from cs242registration.model.model import *
 
 # Finally, call elixir to set up the tables.
 # but not if using reflected tables

File CS242Registration/cs242registration/model/model.py

View file
     time = elixir.Field(elixir.Integer())
     capacity = elixir.Field(elixir.Integer())
     students = elixir.OneToMany("Student", cascade="all")
-    moderator = elixir.ManyToOne("Moderator")
+    moderator = elixir.ManyToOne("Moderator")
+    
+class Config(elixir.Entity):
+    default_section_capacity = elixir.Field(elixir.Integer())
+    registration_open = elixir.Field(elixir.DateTime())
+    registration_close = elixir.Field(elixir.DateTime())

File CS242Registration/cs242registration/tests/functional/test_admin.py

View file
+from cs242registration.tests import *
+
+class TestAdminController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url(controller='admin', action='index'))
+        # Test response...

File CS242Registration/cs242registration/websetup.py

View file
     """Place any commands to setup cs242registration here"""
     load_environment(conf.global_conf, conf.local_conf)
     model.metadata.create_all()
-
-    # Initialisation here ... this sort of stuff:
-
-    # some_entity = model.Session.query(model.<modelfile>.<Some_Entity>).get(1)
-    # e.g. foo = model.Session.query(model.identity.User).get(1)
-    # from datetime import datetime
-    # some_entity.poked_on = datetime.now()
-    # model.Session.add(some_entity)
     cemeyer = Moderator(netid="cemeyer2",admin=True)
+    log.debug("created moderator")
     model.Session.commit()
+    log.debug("committed session")

File CS242Registration/data/sessions/container_file/9/90/90f1d4f5fce2976097b5edf667c83a01.cache

View file
 (dp3
 S'_accessed_time'
 p4
-F1276878505.096164
+F1276879826.706682
 sS'user'
 p5
 ccopy_reg

File CS242Registration/development.db

Binary file modified.