1. Charlie Meyer
  2. CS242Registration

Commits

cemeyer2  committed ff58886

started work on templates

  • Participants
  • Parent commits 54e786b
  • Branches default

Comments (0)

Files changed (13)

File CS242Registration/cs242registration/controllers/admin.py

View file
 from pylons.controllers.util import abort, redirect_to
 
 from cs242registration.lib.base import BaseController, render
+from cs242registration.model import Session
+from cs242registration.model import Moderator, Section
+from cs242registration.lib import helpers as h
 
 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'
+        admin = h.get_user()
+        moderators = Moderator.query.all()
+        sections = Section.query.all()
+        c.admin = admin
+        c.moderators = moderators
+        c.sections = sections
+        return render('/derived/admin/index.html')
+    
+    def add_moderator(self):
+        netid = request.params['netid']
+        admin = bool(int(request.params['admin']))
+        moderator = Moderator(netid=netid, admin=admin)
+        return redirect_to(controller='admin', action='index')
+    
+    def remove_moderator(self):
+        id = request.params['id']
+        moderator = h.get_object_or_404(Moderator, id=id)
+        for section in moderator.sections:
+            section.moderator = None
+        Session.delete(moderator)
+        Session.commit()
+        return redirect_to(controller='admin', action='index')
+    
+    def add_section(self):
+        moderator_id = request.params['moderator_id']
+        moderator = h.get_object_or_404(Moderator, moderator_id)
+        day = int(request.params['day'])
+        time = int(request.params['time'])
+        capacity = int(request.params['capacity'])
+        section = Section(moderator=moderator, day=day, time=time, capacity=capacity)
+        Session.commit()
+        return redirect_to(controller='admin', action='index')
+        

File CS242Registration/cs242registration/controllers/moderator.py

View file
 from pylons.controllers.util import abort, redirect_to
 
 from cs242registration.lib.base import BaseController, render
+from cs242registration.lib import helpers as h
 
 log = logging.getLogger(__name__)
 
 class ModeratorController(BaseController):
 
     def index(self):
-        moderator = session['user']
+        moderator = h.get_user()
         sections = moderator.sections
         c.moderator = moderator
         c.sections = sections

File CS242Registration/cs242registration/controllers/student.py

View file
 class StudentController(BaseController):
 
     def index(self):
-        student = session['user']
+        student = h.get_user()
         section = student.section
         c.student = student
         c.section = section
         return render('/derived/student/index.html')
     
     def register(self, id):
-        student = session['user']
+        student = h.get_user()
         new_section = h.get_object_or_404(Section, id=id)
         if student.section is not None:
             old_section = student.section

File CS242Registration/cs242registration/model/model.py

View file
     students = elixir.OneToMany("Student", cascade="all")
     moderator = elixir.ManyToOne("Moderator")
     
+    def __str__(self):
+        sday = "Monday"
+        if self.day == 2:
+            sday = "Tueday"
+        elif self.day == 3:
+            sday = "Wednesday"
+        elif self.day == 4:
+            sday = "Thursday"
+        elif self.day == 5:
+            sday = "Friday"
+        elif self.day == 6:
+            sday = "Saturday"
+        elif self.day == 7:
+            sday = "Sunday"
+        return sday + " from "+str(self.time)+":00 to "+str(self.time+1)+":50"
+    
 class Config(elixir.Entity):
     default_section_capacity = elixir.Field(elixir.Integer())
     registration_open = elixir.Field(elixir.DateTime())

File CS242Registration/cs242registration/public/default.css

View file
+
+/*
+Design by Free CSS Templates
+http://www.freecsstemplates.org
+Released for free under a Creative Commons Attribution 2.5 License
+*/
+
+body {
+	margin: 0;
+	padding: 0;
+	background: #EBEBEB url(images/img01.gif) repeat-x left top;
+	text-align: justify;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	color: #454545;
+}
+
+h1, h2, h3 {
+	margin-top: 0;
+	color: #8C0209;
+}
+
+h1 {
+	font-size: 1.6em;
+	font-weight: normal;
+}
+
+h2 {
+	font-size: 1.6em;
+}
+
+h3 {
+	font-size: 1em;
+}
+
+ul {
+}
+
+a {
+	text-decoration: none;
+	color: #3F5C10;
+}
+
+a:hover {
+	border-bottom: none;
+}
+
+a img {
+	border: none;
+}
+
+img.left {
+	float: left;
+	margin: 0 20px 0 0;
+}
+
+img.right {
+	float: right;
+	margin: 0 0 0 20px;
+}
+
+#header {
+	width: 1000px;
+	height: 203px;
+	margin: 0 auto;
+}
+
+/* Header */
+
+#logo {
+	width: 960px;
+	height: 150px;
+	margin: 0 auto;
+	background: url(images/img02.jpg) no-repeat left top;
+}
+
+#logo h1, #logo p {
+	float: left;
+	margin: 0px;
+}
+
+#logo span {
+	color: #FFFFFF;
+}
+
+#logo h1 {
+	padding-top: 40px;
+	letter-spacing: -1px;
+	text-transform: lowercase;
+	font-weight: normal;
+	font-size: 5em;
+}
+
+#logo p {
+	display: block;
+	padding-top: 80px;
+	text-transform: uppercase;
+	font-size: 10px;
+	color: #FFFFFF;
+}
+
+#logo a {
+	border: none;
+	text-decoration: none;
+	color: #FFFFFF;
+}
+
+/* Menu */
+
+#menu {
+	width: 960px;
+	margin: 0 auto;
+	padding: 0;
+	height: 50px;
+	background: #BF3503;
+}
+
+#menu ul {
+	margin: 0;
+	padding: 0;
+	list-style: none;
+}
+
+#menu li {
+	display: inline;
+}
+
+#menu a {
+	display: block;
+	float: left;
+	margin: 1px 0px 0px 0px;
+	padding: 15px 35px 0px 35px;
+	text-decoration: none;
+	text-transform: capitalize;
+	font-size: 12px;
+	color: #FFFFFF;
+}
+
+#menu a:hover {
+	color: #FFFFFF;
+}
+
+#menu .current_page_item a {
+	color: #FFFFFF;
+}
+
+#menu .first {
+	background: none;
+}
+
+/* Wrapper */
+
+#wrapper {
+}
+
+/* Page */
+
+#page {
+	width: 960px;
+	margin: 0 auto;
+	background: url(images/img05.gif) repeat-y left top;
+}
+
+#page-bg {
+	background: url(images/img06.gif) no-repeat left top;
+	padding: 0px 10px;
+}
+
+/* Latest Post */
+
+#latest-post {
+	padding: 20px;
+	border: 1px solid #E7E7E7;
+}
+
+/* Content */
+
+#content {
+	float: left;
+	width: 440px;
+	padding: 30px 40px 0px 40px;
+}
+
+.post {
+	padding-bottom: 45px;
+	line-height: 200%;
+}
+
+.post h1 {
+	font-weight: normal;
+}
+
+.title {
+	margin: 0px;
+	padding: 0px 0px 14px 0px;
+	letter-spacing: -1px;
+	font-size: 3em;
+	font-weight: normal;
+	background: url(images/img04.gif) repeat-x left bottom;
+}
+
+.title a {
+	border-bottom: none;
+	color: #454545;
+}
+
+.title a:hover {
+}
+
+.byline {
+	background: url(images/img04.jpg) repeat-x left bottom;
+	padding-bottom: 10px;
+}
+
+.tag {
+	padding: 0 15px;
+}
+
+.entry {
+}
+
+.links {
+	padding: 4px 0px;
+	text-align: right;
+	font-weight: bold;
+}
+
+.links a {
+	border: none;
+}
+
+.links a:hover {
+}
+
+/* Sidebars */
+
+#sidebar1 {
+	float: left;
+}
+
+#sidebar2 {
+	float: right;
+}
+
+.sidebar {
+	float: left;
+	width: 210px;
+	padding: 0;
+	font-size: 12px;
+}
+
+.sidebar ul {
+	margin: 0;
+	padding: 0;
+	list-style: none;
+}
+
+.sidebar li {
+	padding: 0 0 20px 0;
+}
+
+.sidebar li ul {
+	padding: 10px 0px;
+}
+
+.sidebar li li {
+	margin: 0 20px 0 15px;
+	padding: 8px 0px;
+	background: url(images/img04.gif) repeat-x left bottom;
+}
+
+
+.sidebar li h2 {
+	height: 34px;
+	margin: 0 0 0 0;
+	padding: 12px 15px 0px 15px;
+	font-size: 20px;
+	font-weight: normal;
+	color: #000000;
+}
+
+.sidebar a {
+}
+
+/* Search */
+
+#searchform {
+	margin: 0;
+	padding: 0 0 0 0;
+}
+
+#searchform br {
+	display: none;
+}
+
+#searchform h2 {
+}
+
+#s {
+	margin: 10px 0px 0 15px;
+	padding: 2px 2px;
+	width: 180px;
+	height: 18px;
+	border: none;
+	background: #FFFFFF;
+	font-size: 10px;
+	color: #000000;
+}
+
+#x {
+	margin: 0;
+	padding: 2px 5px;
+	height: 25px;
+	background: #CA8186;
+	text-decoration: none;
+	text-transform: uppercase;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 10px;
+	color: #CCCCCC;
+}
+/* Calendar */
+
+#calendar_wrap {
+	padding: 0 15px;
+	text-align: center;
+}
+
+#calendar_wrap table {
+	width: 100%;
+}
+
+#calendar_wrap th {
+}
+
+#calendar_wrap td {
+}
+
+#calendar_wrap tfoot td {
+	border: none;
+}
+
+#calendar_wrap tfoot td#prev {
+	text-align: left;
+	font-weight: bold;
+	border: none;
+}
+
+#calendar_wrap tfoot td#prev a {
+	border: none;
+}
+
+#calendar_wrap tfoot td#next {
+	text-align: right;
+	font-weight: bold;
+	border: none;
+}
+
+#calendar_wrap tfoot td#next a {
+	border: none;
+}
+
+/* Footer */
+
+#footer {
+	width: 100%;
+	height: 70px;
+	margin: 0 auto;
+	background: #161600;
+}
+
+#footer-bg {
+	width: 960px;
+	margin: 0 auto;
+}
+
+#footer p {
+	margin: 0;
+	padding: 25px 0 0 0;
+	text-align: center;
+	font-size: smaller;
+}
+
+#footer a {
+	color: #E7E7E7;
+}
+
+#footer .link {
+	float: right;
+}
+
+#footer .copyright {
+	float: left;
+}

File CS242Registration/cs242registration/public/images/PythonPowered.png

Added
New image

File CS242Registration/cs242registration/public/images/img01.gif

Added
New image

File CS242Registration/cs242registration/public/images/img04.gif

Added
New image

File CS242Registration/cs242registration/public/images/img05.gif

Added
New image

File CS242Registration/cs242registration/public/images/img06.gif

Added
New image

File CS242Registration/cs242registration/templates/base/index.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!--
+Design by Free CSS Templates
+http://www.freecsstemplates.org
+Released for free under a Creative Commons Attribution 2.5 License
+
+Name       : Nourish 
+Description: A three-column, fixed-width blog design.
+Version    : 1.0
+Released   : 20090811
+
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>${self.title()}</title>
+<meta name="keywords" content="" />
+<meta name="Premium Series" content="" />
+<link href="${h.url_for('/default.css')}" rel="stylesheet" type="text/css" media="screen" />
+${self.js()}
+</head>
+<body>
+<!-- start header -->
+<div id="header">
+	<div id="logo">
+		<h1><a href="#"><span>cs242 </span></a></h1>
+		<p>discussion section registration</p>
+	</div>
+	<div id="menu">
+		<ul id="main">
+			<li><a href="${h.url_for(controller='registration', action='index')}">Home</a></li>
+						<li><a href="http://cs.illinois.edu/class/cs242/">Course Webpage</a></li>
+						<li><a href="http://cs.illinois.edu">CS Home</a></li>
+						<li><a href="${h.url_for(controller='admin', action='index')}">Admin</a></li>
+		</ul>
+	</div>
+</div>
+<!-- end header -->
+<div id="wrapper">
+	<!-- start page -->
+	<div id="page">
+	<div id="page-bg">
+		<div id="sidebar1" class="sidebar">
+			<ul>
+				<li>
+					<h2>Links</h2>
+					<ul>
+						<li><a href="${h.url_for(controller='registration', action='index')}">Home</a></li>
+						<li><a href="http://cs.illinois.edu/class/cs242/">Course Webpage</a></li>
+						<li><a href="http://cs.illinois.edu">CS Home</a></li>
+						<li><a href="${h.url_for(controller='admin', action='index')}">Admin</a></li>
+					</ul>
+				</li>
+			</ul>
+		</div>
+		<!-- start content -->
+		<div id="content">
+			<div class="flower"></div>
+			<div class="post">
+				<h1 class="title"><a href="#">${self.heading()}</a></h1>
+				<!--<p class="byline"><small>Posted on October 1st, 2009 by <a href="#">Free CSS Templates</a></small></p> -->
+				<div class="entry">
+					${next.body()}
+				</div>
+			</div>
+		</div>
+		<!-- end content -->
+		<!-- start sidebars -->
+		<div id="sidebar2" class="sidebar">
+			
+		</div>
+		<!-- end sidebars -->
+		<div style="clear: both;">&nbsp;</div>
+	</div>
+	<!-- end page -->
+</div>
+</div>
+<div id="footer">
+<div id="footer-bg">
+	<p class="copyright">Written by <a href="mailto:cemeyer2 at illinois dot edu">Charlie Meyer</a>; Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
+	<br /><br /><br /><br /><br /><br />
+	<p>
+		<img src="${h.url_for('/images/PythonPowered.png')}"/>
+	</p>
+</div>
+</div>
+</body>
+</html>
+<%def name="title()">CS242 Discussion Section Registration</%def>
+<%def name="js()">
+
+<script>
+</script>
+</%def>
+<%def name="header()"><a name="top"></a></%def>
+<%def name="heading()"><h1>${c.heading or 'No Title'}</h1></%def>

File CS242Registration/cs242registration/templates/derived/moderator/index.html

View file
+<%inherit file="/base/index.html" />
+
+<ul>
+% for section in c.sections:
+	<li>
+		${str(section)}
+		<ul>
+% for student in section.students:
+				<li>
+					${student.netid}
+				</li>
+% endfor			
+		</ul>
+	</li>
+% endfor
+</ul>
+
+<%def name="heading()"><h1>My Sections</h1></%def>
+<%def name="title()">Moderator - ${parent.title()}</%def>

File CS242Registration/development.db

Binary file modified.