Permalink
Browse files

Retreive patches

  • Loading branch information...
1 parent 7057717 commit 43374dca3817343d3b2f1c7335703bbc7fa1a60a @holdenk committed Jan 21, 2013
Showing with 23 additions and 1 deletion.
  1. +8 −0 frontend/unicorn/templates/review.html
  2. +1 −0 frontend/unicorn/verify/models.py
  3. +14 −1 frontend/unicorn/verify/views.py
@@ -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>
@@ -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()
@@ -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")
@@ -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.