mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Fix some bugs in mailings with new club tools
This commit is contained in:
parent
4800db3c2c
commit
8146186447
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -35,7 +35,7 @@
|
||||
{% else %}
|
||||
<td>{% trans %}Unregistered user{% endtrans %}</td>
|
||||
{% endif %}
|
||||
<td>{{ subscriber.email }}</td>
|
||||
<td>{{ subscriber.get_email }}</td>
|
||||
<td><a href="{{ url('club:mailing_subscription_delete', mailing_subscription_id=subscriber.id) }}">{% trans %}Delete{% endtrans %}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -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)
|
||||
|
@ -1226,7 +1226,6 @@ label {
|
||||
}
|
||||
|
||||
#club_detail {
|
||||
|
||||
.club_logo {
|
||||
float: right;
|
||||
img {
|
||||
|
Loading…
Reference in New Issue
Block a user