Notifications: unsubscribe from extension approval activity (#177) #207
@ -80,6 +80,20 @@
|
||||
<section id="activity" class="mt-4">
|
||||
<hr class="my-4">
|
||||
<h2>Activity</h2>
|
||||
{% if request.user.is_authenticated %}
|
||||
<form method="post" action="{% url 'reviewers:approval-follow' extension.slug %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn">
|
||||
{% if user_is_following %}
|
||||
<i class="i-bell-off"></i> Unsubscribe
|
||||
<input type="hidden" name="follow" value="" />
|
||||
{% else %}
|
||||
<i class="i-bell"></i> Subscribe
|
||||
<input type="hidden" name="follow" value="True" />
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if review_activity %}
|
||||
<ul class="activity-list">
|
||||
|
@ -15,4 +15,9 @@ urlpatterns = [
|
||||
views.ExtensionsApprovalFormView.as_view(),
|
||||
name='approval-comment',
|
||||
),
|
||||
path(
|
||||
'approval-queue-follow/<slug:slug>/',
|
||||
views.ExtensionsApprovalFollowView.as_view(),
|
||||
name='approval-follow',
|
||||
),
|
||||
]
|
||||
|
@ -1,12 +1,14 @@
|
||||
from collections import defaultdict
|
||||
import logging
|
||||
|
||||
from actstream.actions import follow, is_following, unfollow
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic.list import ListView
|
||||
from django.views.generic import DetailView, FormView
|
||||
from django.shortcuts import reverse
|
||||
from django.shortcuts import redirect, reverse
|
||||
import django.forms
|
||||
|
||||
from constants.activity import Flag
|
||||
from extensions.models import Extension
|
||||
from reviewers.forms import CommentForm
|
||||
from reviewers.models import ApprovalActivity
|
||||
@ -134,6 +136,7 @@ class ExtensionsApprovalDetailView(DetailView):
|
||||
form.fields['type'].widget.choices = choices
|
||||
if len(choices) == 1:
|
||||
form.fields['type'].widget = django.forms.HiddenInput()
|
||||
ctx['user_is_following'] = is_following(user, self.object, flag=Flag.REVIEWER)
|
||||
return ctx
|
||||
|
||||
|
||||
@ -158,3 +161,16 @@ class ExtensionsApprovalFormView(LoginRequiredMixin, FormView):
|
||||
form.save()
|
||||
self.approve_if_allowed(form)
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
class ExtensionsApprovalFollowView(LoginRequiredMixin, DetailView):
|
||||
model = Extension
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
extension = self.get_object()
|
||||
user = request.user
|
||||
if request.POST.get('follow'):
|
||||
follow(user, extension, flag=Flag.REVIEWER)
|
||||
else:
|
||||
unfollow(user, extension, flag=Flag.REVIEWER)
|
||||
return redirect(extension.get_review_url() + '#activity')
|
||||
|
Loading…
Reference in New Issue
Block a user