diff --git a/api/views/club.py b/api/views/club.py index 42d70eb6..e4d4b30a 100644 --- a/api/views/club.py +++ b/api/views/club.py @@ -58,6 +58,6 @@ def FetchMailingLists(request): if key != settings.SITH_MAILING_FETCH_KEY: raise PermissionDenied data = '' - for mailing in Mailing.objects.filter(is_moderated=True, club__is_active=False).all(): + for mailing in Mailing.objects.filter(is_moderated=True, club__is_active=True).all(): data += mailing.fetch_format() + "\n" return Response(data) diff --git a/club/models.py b/club/models.py index 16d85be9..81c92ef2 100644 --- a/club/models.py +++ b/club/models.py @@ -347,8 +347,14 @@ class MailingSubscription(models.Model): def can_be_edited_by(self, user): return (self.user is not None and user.id == self.user.id) + @property + def get_email(self): + if self.user and not self.email: + return self.user.email + return self.email + def fetch_format(self): - return self.email + ' ' + return self.get_email + ' ' def __str__(self): if self.user: diff --git a/club/templates/club/mailing.jinja b/club/templates/club/mailing.jinja index ad1f1432..9c2af2b8 100644 --- a/club/templates/club/mailing.jinja +++ b/club/templates/club/mailing.jinja @@ -35,7 +35,7 @@ {% else %} {% trans %}Unregistered user{% endtrans %} {% endif %} - {{ subscriber.email }} + {{ subscriber.get_email }} {% trans %}Delete{% endtrans %} {% endfor %} diff --git a/club/views.py b/club/views.py index edaaf40c..4841c56e 100644 --- a/club/views.py +++ b/club/views.py @@ -563,6 +563,7 @@ class MailingSubscriptionDeleteView(CanEditMixin, DeleteView): def get_success_url(self, **kwargs): return reverse_lazy('club:mailing', kwargs={'club_id': self.club_id}) + class MailingAutoGenerationView(View): def dispatch(self, request, *args, **kwargs): @@ -573,13 +574,13 @@ class MailingAutoGenerationView(View): def get(self, request, *args, **kwargs): club = self.mailing.club - already_subscribed = [sub.user for sub in self.mailing.subscriptions.all()] - members = club.members.filter(role__gte=settings.SITH_CLUB_ROLES_ID['Board member']) - members = members.exclude(user__in=already_subscribed) + self.mailing.subscriptions.all().delete() + members = club.members.filter(role__gte=settings.SITH_CLUB_ROLES_ID['Board member']).exclude(end_date__lte=timezone.now()) for member in members.all(): MailingSubscription(user=member.user, mailing=self.mailing).save() return redirect('club:mailing', club_id=club.id) + class MailingAutoCleanView(View): def dispatch(self, request, *args, **kwargs): @@ -589,6 +590,5 @@ class MailingAutoCleanView(View): return super(MailingAutoCleanView, self).dispatch(request, *args, **kwargs) def get(self, request, *args, **kwargs): - for sub in self.mailing.subscriptions.all(): - sub.delete() + self.mailing.subscriptions.all().delete() return redirect('club:mailing', club_id=self.mailing.club.id) diff --git a/core/static/core/style.scss b/core/static/core/style.scss index dfc37b72..7032d14a 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -1226,7 +1226,6 @@ label { } #club_detail { - .club_logo { float: right; img {