diff options
author | Magnus Hagander | 2014-07-15 09:50:10 +0000 |
---|---|---|
committer | Magnus Hagander | 2014-07-15 09:50:10 +0000 |
commit | 0eba14c4159a492edfa9e66fab0403440645154f (patch) | |
tree | 51d433c7d5fbb098e6e7d139cb441745244b00f5 /pgcommitfest/commitfest/views.py | |
parent | dc3c89cc70246a31fedafecf9c8863e209b244b6 (diff) |
Add proper support for committing patches
This will prompt for who was the committer, and default to either the user
listed as a committer if there is one, or to the current user if the current
user happens to be a committer.
Diffstat (limited to 'pgcommitfest/commitfest/views.py')
-rw-r--r-- | pgcommitfest/commitfest/views.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index a7217a0..0230c41 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -123,11 +123,12 @@ def patch(request, cfid, patchid): cf = get_object_or_404(CommitFest, pk=cfid) patch = get_object_or_404(Patch.objects.select_related(), pk=patchid, commitfests=cf) patch_commitfests = PatchOnCommitFest.objects.select_related('commitfest').filter(patch=patch).order_by('-commitfest__startdate') + committers = Committer.objects.filter(active=True).order_by('user__last_name', 'user__first_name') #XXX: this creates a session, so find a smarter way. Probably handle #it in the callback and just ask the user then? if request.user.is_authenticated(): - committer = list(Committer.objects.filter(user=request.user, active=True)) + committer = [c for c in committers if c.user==request.user] if len(committer) > 0: is_committer= True is_this_committer = committer[0] == patch.committer @@ -135,7 +136,6 @@ def patch(request, cfid, patchid): is_committer = is_this_committer = False is_reviewer = request.user in patch.reviewers.all() -# is_reviewer = len([x for x in patch.reviewers.all() if x==request.user]) > 0 else: is_committer = False is_this_committer = False @@ -148,6 +148,7 @@ def patch(request, cfid, patchid): 'is_committer': is_committer, 'is_this_committer': is_this_committer, 'is_reviewer': is_reviewer, + 'committers': committers, 'title': patch.name, 'breadcrumbs': [{'title': cf.title, 'href': '/%s/' % cf.pk},], }, context_instance=RequestContext(request)) @@ -383,10 +384,12 @@ def close(request, cfid, patchid, status): newpoc = PatchOnCommitFest(patch=poc.patch, commitfest=newcf[0], enterdate=datetime.now()) newpoc.save() elif status == 'committed': + committer = get_object_or_404(Committer, user__username=request.GET['c']) + if committer != poc.patch.committer: + # Committer changed! + poc.patch.committer = committer + PatchHistory(patch=poc.patch, by=request.user, what='Changed committer to %s' % committer).save() poc.status = PatchOnCommitFest.STATUS_COMMITTED - #XXX: need to prompt for a committer here! - raise Exception("Need to prompt for committed if the user who just committed isn't one!") - poc.patch.committer = Committer.objects.get(user=request.user) else: raise Exception("Can't happen") |