Skip to content

Commit

Permalink
Retreive patches
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Jan 21, 2013
1 parent 7057717 commit 43374dc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions frontend/unicorn/templates/review.html
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
Welcome {{ghusername}}!
{% if newpatch %}
What do you think of the following review:
<iframe src="{% url reviewlink %}"></iframe>
<from action="/review" method="POST">
{% else %}
We have run out of patches to have reviewed! Thanks so much!
{% endif %}
</form>
1 change: 1 addition & 0 deletions frontend/unicorn/verify/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ class PatchInfo(models.Model):
default=False)
exported = models.BooleanField(max_length=1000, help_text="Has this patch been examined",
default=False)
touched_time = models.DateTimeField()

15 changes: 14 additions & 1 deletion frontend/unicorn/verify/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.contrib.auth.decorators import login_required
from models import PatchInfo
from social_auth.models import *
from django.db.models import Q
from datetime import date, timedelta, datetime

def index(request):
t = loader.get_template("index.html")
Expand All @@ -15,5 +17,16 @@ def review(request):
t = loader.get_template("review.html")
social = UserSocialAuth.objects.filter(user = request.user)
githubusername = social[0].user
c = Context({'ghusername' : githubusername})
# Fetch a patch that has not been examined and is either has no reviewer
# the current user as the reviewer OR is more than 2 days since last
# given to a reviewer
newpatch = False
patch = None
try:
patch = PatchInfo.objects.get(Q(examined=False), Q(reviewer_username = '') | Q(reviewer_username = githubusername) | Q(touched_time__lte=date.today() - timedelta(2)))[0]
patch.username = githubusername
patch.touched_time = datetime.now()
except Exception, err:
newpatches = True
c = Context({'ghusername' : githubusername, 'patch': patch, 'newpatch': newpatch})
return HttpResponse(t.render(c))

0 comments on commit 43374dc

Please sign in to comment.