1717from patchwork .models import Bundle
1818from patchwork .models import Cover
1919from patchwork .models import Patch
20+ from patchwork .models import PatchReviewIntention
2021from patchwork .models import Project
2122from patchwork .views import generic_list
2223from patchwork .views .utils import patch_to_mbox
@@ -102,6 +103,30 @@ def patch_detail(request, project_id, msgid):
102103 'Failed to add patch "%s" to bundle "%s": '
103104 'patch is already in bundle' % (patch .name , bundle .name ),
104105 )
106+ elif action == 'add-review' :
107+ if request .user .is_authenticated :
108+ PatchReviewIntention .objects .get_or_create (
109+ patch = patch ,
110+ user = request .user
111+ )
112+ patch .has_planned_review = patch .planning_to_review .exists ()
113+ patch .save ()
114+
115+ messages .success (request , "You have declared interest in reviewing this patch." )
116+ else :
117+ messages .error (request , "You must be logged in to declare review interest." )
118+
119+ elif action == 'remove-review' :
120+ if request .user .is_authenticated :
121+ PatchReviewIntention .objects .filter (
122+ patch = patch ,
123+ user = request .user
124+ ).delete ()
125+ patch .has_planned_review = patch .planning_to_review .exists ()
126+ patch .save ()
127+ messages .success (request , "You have removed your interest in reviewing this patch." )
128+ else :
129+ messages .error (request , "You must be logged in to remove review interest." )
105130
106131 # all other actions require edit privs
107132 elif not editable :
@@ -116,6 +141,17 @@ def patch_detail(request, project_id, msgid):
116141 if request .user .is_authenticated :
117142 context ['bundles' ] = request .user .bundles .all ()
118143
144+ intentions = PatchReviewIntention .objects .filter (patch = patch )
145+
146+ context ['intentions' ] = intentions
147+ context ['planning_to_review' ] = False
148+ context ['review_expiry_date' ] = None
149+ for intention in intentions :
150+ intention .review_expiry_date = intention .last_time_marked_for_review + patch .state .review_intention_expiration_time
151+ if intention .user == request .user :
152+ context ['planning_to_review' ] = True
153+ context ['review_expiry_date' ] = intention .last_time_marked_for_review + patch .state .review_intention_expiration_time
154+
119155 comments = patch .comments .all ()
120156 comments = comments .select_related ('submitter' )
121157 comments = comments .only (
0 commit comments