diff options
author | raylu <raylu@cmu.edu> | 2011-05-16 01:19:04 -0400 |
---|---|---|
committer | raylu <raylu@cmu.edu> | 2011-05-16 01:19:04 -0400 |
commit | f60a3158947a566518522af14ec4b92acfaea3d1 (patch) | |
tree | 780646d29a8d55bdd8d216b56ab9954ce8b7e710 | |
parent | f377715900bb5c95938ef749eeebb944c5c9bd2d (diff) | |
download | pyc-f60a3158947a566518522af14ec4b92acfaea3d1.tar.xz |
Site design
-rw-r--r-- | pyc/grader/context_processors.py | 6 | ||||
-rw-r--r-- | pyc/grader/views.py | 16 | ||||
-rw-r--r-- | pyc/settings.py | 6 | ||||
-rw-r--r-- | pyc/templates/base.html | 27 | ||||
-rw-r--r-- | pyc/templates/faq.html | 4 | ||||
-rw-r--r-- | pyc/templates/index.html | 19 | ||||
-rw-r--r-- | pyc/templates/lab.html | 2 | ||||
-rw-r--r-- | static/style.css | 47 |
8 files changed, 93 insertions, 34 deletions
diff --git a/pyc/grader/context_processors.py b/pyc/grader/context_processors.py new file mode 100644 index 0000000..6067b5e --- /dev/null +++ b/pyc/grader/context_processors.py @@ -0,0 +1,6 @@ +def nav(request): + from grader.models import Lab + return { + 'labs': Lab.objects.all(), + 'authenticated' : request.user.is_authenticated() + } diff --git a/pyc/grader/views.py b/pyc/grader/views.py index e74d540..1cf83ec 100644 --- a/pyc/grader/views.py +++ b/pyc/grader/views.py @@ -8,13 +8,12 @@ from grader.models import Lab, Submission import os def index(request): - return render_to_response('index.html', { - 'labs' : Lab.objects.all(), - 'authenticated' : request.user.is_authenticated(), - }) + return render_to_response('index.html', + context_instance=RequestContext(request)) def password_changed(request): - return render_to_response('password_changed.html') + return render_to_response('password_changed.html', + context_instance=RequestContext(request)) def lab(request, lab_id): from datetime import timedelta @@ -35,7 +34,7 @@ def lab(request, lab_id): 'lab' : lab, 'submissions' : submissions, 'staff' : request.user.is_staff - }) + }, context_instance=RequestContext(request)) @login_required def submit(request, lab_id): @@ -90,10 +89,11 @@ def submission(request, lab_id, user_id): f.close() return render_to_response('submission.html', { 'code' : code, - }) + }, context_instance=RequestContext(request)) def faq(request): - return render_to_response('faq.html') + return render_to_response('faq.html', {}, + context_instance=RequestContext(request)) def grade(file, id): import subprocess diff --git a/pyc/settings.py b/pyc/settings.py index 75d27be..5a903e7 100644 --- a/pyc/settings.py +++ b/pyc/settings.py @@ -113,6 +113,12 @@ TEMPLATE_DIRS = ( path.join(path.dirname(__file__), 'templates'), ) +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.contrib.auth.context_processors.auth', + 'django.core.context_processors.i18n', + 'pyc.grader.context_processors.nav', +) + INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/pyc/templates/base.html b/pyc/templates/base.html index 6779635..00dac18 100644 --- a/pyc/templates/base.html +++ b/pyc/templates/base.html @@ -6,6 +6,33 @@ <link href="/static/style.css" rel="stylesheet" type="text/css" charset="utf8"> </head> <body> +<div id="wrap"> + <div id="content"> {% block body %}{% endblock %} + </div> + <div id="nav"> + <div class="nav"> + <a href="{% url grader.views.index %}">Home</a> + + <p>Labs: + <ol> + {% for lab in labs %} + <li><a href="/lab/{{ lab.id }}/">{{ lab.name }}</a></li> + {% endfor %} + </ol></p> + + <a href="{% url grader.views.faq %}">FAQ</a> + </div> + <div class="nav"> + {% if authenticated %} + <a href="{% url django.contrib.auth.views.password_change %}">Change Password</a> + <br /> + <a href="{% url django.contrib.auth.views.logout %}">Logout</a> + {% else %} + <a href="{% url django.contrib.auth.views.login %}">Login</a> + {% endif %} + </div> + </div> +</div> </body> </html> diff --git a/pyc/templates/faq.html b/pyc/templates/faq.html index cd76f90..bf73fc0 100644 --- a/pyc/templates/faq.html +++ b/pyc/templates/faq.html @@ -44,8 +44,4 @@ Yes. </p> </li> </ol> - -<p> -<a href="/">Home</a> -</p> {% endblock %} diff --git a/pyc/templates/index.html b/pyc/templates/index.html index f99165d..9c6faa5 100644 --- a/pyc/templates/index.html +++ b/pyc/templates/index.html @@ -1,12 +1,5 @@ {% extends 'base.html' %} {% block body %} -Labs: -<ol> -{% for lab in labs %} - <li><a href="/lab/{{ lab.id }}/">{{ lab.name }}</a></li> -{% endfor %} -</ol> - <p> pyc is a way to learn Python through competition. <br /> @@ -16,16 +9,4 @@ Submit your code online and be automatically graded and ranked. <br /> If you are interested, please contact raylu. </p> - -<p> -{% if authenticated %} - <a href="{% url django.contrib.auth.views.password_change %}">Change Password</a> - <br /> - <a href="{% url django.contrib.auth.views.logout %}">Logout</a> -{% else %} - <a href="{% url django.contrib.auth.views.login %}">Login</a> -{% endif %} -<br /> -<a href="{% url grader.views.faq %}">FAQ</a> -</p> {% endblock %} diff --git a/pyc/templates/lab.html b/pyc/templates/lab.html index 4194edc..2743ecb 100644 --- a/pyc/templates/lab.html +++ b/pyc/templates/lab.html @@ -27,7 +27,5 @@ Lab {{ lab.id }} due {{ lab.due }} at 11:59:59 PDT (UTC-7): <p> <a href="/submit/{{ lab.id }}/">Submit</a> your solution -<br> -<a href="/">Back</a> to the homepage </p> {% endblock %} diff --git a/static/style.css b/static/style.css index 0c37846..395dfd1 100644 --- a/static/style.css +++ b/static/style.css @@ -1,3 +1,42 @@ +body { + background-color: #000; + color: #eee; +} + +a, a:visited, a:active { + color: #08a; + text-decoration: none; +} +a:hover { + color: #0ae; + text-decoration: underline; +} + +#wrap { + width: 1000px; + margin: auto; + margin-top: 25px; +} + +#wrap #content { + width: 750px; + background-color: #111; + padding: 15px; + float: right; +} + +#wrap #nav { + float: left; + width: 175px; +} + +#wrap #nav div.nav { + width: 175px; + background-color: #111; + padding: 15px; + margin-bottom: 15px; +} + table#lab { border-collapse: collapse; border: 1px solid #000; @@ -10,5 +49,11 @@ table#lab { padding: 5px; } #lab tr.staff td { - background-color: #ddd; + color: #888; +} + +input { + background-color: #111; + color: #eee; + border: 1 solid #eee; } |