From f60a3158947a566518522af14ec4b92acfaea3d1 Mon Sep 17 00:00:00 2001 From: raylu Date: Mon, 16 May 2011 01:19:04 -0400 Subject: Site design --- pyc/grader/context_processors.py | 6 +++++ pyc/grader/views.py | 16 +++++++------- pyc/settings.py | 6 +++++ pyc/templates/base.html | 27 +++++++++++++++++++++++ pyc/templates/faq.html | 4 ---- pyc/templates/index.html | 19 ---------------- pyc/templates/lab.html | 2 -- static/style.css | 47 +++++++++++++++++++++++++++++++++++++++- 8 files changed, 93 insertions(+), 34 deletions(-) create mode 100644 pyc/grader/context_processors.py 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 @@ +
+
{% block body %}{% endblock %} +
+ +
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.

- -

-Home -

{% 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: -
    -{% for lab in labs %} -
  1. {{ lab.name }}
  2. -{% endfor %} -
-

pyc is a way to learn Python through competition.
@@ -16,16 +9,4 @@ Submit your code online and be automatically graded and ranked.
If you are interested, please contact raylu.

- -

-{% if authenticated %} - Change Password -
- Logout -{% else %} - Login -{% endif %} -
-FAQ -

{% 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):

Submit your solution -
-Back to the homepage

{% 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; } -- cgit v1.2.3