Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f7d3e
commit 28eb333
Showing
11 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
# Uncomment the next two lines to enable the admin: | ||
# from django.contrib import admin | ||
# admin.autodiscover() | ||
|
||
urlpatterns = patterns('web.home.views', | ||
(r'^register/$', 'register'), | ||
(r'^logout/$', 'logout'), | ||
(r'^login/$', 'login'), | ||
(r'^$', 'home'), | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django import forms | ||
from django.db import models as d_models | ||
|
||
import models | ||
|
||
import hashlib | ||
|
||
class SubmissionForm( forms.ModelForm ): | ||
data = forms.FileField(label="Bot Binary") | ||
class Meta: | ||
model = models.Submission | ||
exclude = ('timestamp','team', 'sha1sum') | ||
|
||
def clean(self): | ||
forms.ModelForm.clean(self) | ||
self.clean_sha1sum() | ||
self.cleaned_data["data"].name = self.cleaned_data["sha1sum"] | ||
return self.cleaned_data | ||
|
||
def clean_sha1sum(self): | ||
data = self.cleaned_data["data"] | ||
self.cleaned_data["sha1sum"] = hashlib.sha1(data.read()).hexdigest() | ||
print self.cleaned_data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.db import models | ||
|
||
from web.home import models as home_models | ||
|
||
class Submission( models.Model ): | ||
team = models.ForeignKey( home_models.Team ) | ||
timestamp = models.DateTimeField( auto_now = True ) | ||
sha1sum = models.CharField( max_length=100 ) | ||
data = models.FileField( upload_to='bots' ) | ||
comments = models.TextField() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block body %} | ||
<div> | ||
<div id="add-submission"> | ||
<form method="POST" action="" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
<table> | ||
{{form}} | ||
<tr> | ||
<td></td> | ||
<td> | ||
<span class="right"> | ||
<input type="submit" value="Submit" /> | ||
</span> | ||
</td> | ||
</table> | ||
|
||
</form> | ||
</div> | ||
<div id="view-submission"> | ||
|
||
</div> | ||
</div> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
This file demonstrates two different styles of tests (one doctest and one | ||
unittest). These will both pass when you run "manage.py test". | ||
Replace these with more appropriate tests for your application. | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
class SimpleTest(TestCase): | ||
def test_basic_addition(self): | ||
""" | ||
Tests that 1 + 1 always equals 2. | ||
""" | ||
self.failUnlessEqual(1 + 1, 2) | ||
|
||
__test__ = {"doctest": """ | ||
Another way to test that 1 + 1 is equal to 2. | ||
>>> 1 + 1 == 2 | ||
True | ||
"""} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('web.judge.views', | ||
(r'^manage/$', 'manage'), | ||
(r'^standings/$', 'standings'), | ||
(r'^results/$', 'results'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Create your views here. | ||
|
||
from django.shortcuts import render_to_response | ||
from django.template.context import RequestContext | ||
from django.http import HttpResponse, HttpResponseRedirect | ||
import django.contrib.auth as auth | ||
import django.contrib.auth.views as auth_views | ||
import forms | ||
import models | ||
|
||
from web import settings | ||
|
||
def manage(request): | ||
if request.POST: | ||
data = request.POST | ||
file_data = request.FILES | ||
sub = models.Submission(team = request.user) | ||
form = forms.SubmissionForm(data=data, files=file_data, instance=sub) | ||
if form.is_valid(): | ||
form.save() | ||
else: | ||
form = forms.SubmissionForm() | ||
|
||
return render_to_response("manage.html", | ||
{'form':form}, | ||
context_instance = RequestContext(request)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters