mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +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:
|
if key != settings.SITH_MAILING_FETCH_KEY:
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
data = ''
|
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"
|
data += mailing.fetch_format() + "\n"
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
@ -347,8 +347,14 @@ class MailingSubscription(models.Model):
|
|||||||
def can_be_edited_by(self, user):
|
def can_be_edited_by(self, user):
|
||||||
return (self.user is not None and user.id == self.user.id)
|
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):
|
def fetch_format(self):
|
||||||
return self.email + ' '
|
return self.get_email + ' '
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.user:
|
if self.user:
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<td>{% trans %}Unregistered user{% endtrans %}</td>
|
<td>{% trans %}Unregistered user{% endtrans %}</td>
|
||||||
{% endif %}
|
{% 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>
|
<td><a href="{{ url('club:mailing_subscription_delete', mailing_subscription_id=subscriber.id) }}">{% trans %}Delete{% endtrans %}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -563,6 +563,7 @@ class MailingSubscriptionDeleteView(CanEditMixin, DeleteView):
|
|||||||
def get_success_url(self, **kwargs):
|
def get_success_url(self, **kwargs):
|
||||||
return reverse_lazy('club:mailing', kwargs={'club_id': self.club_id})
|
return reverse_lazy('club:mailing', kwargs={'club_id': self.club_id})
|
||||||
|
|
||||||
|
|
||||||
class MailingAutoGenerationView(View):
|
class MailingAutoGenerationView(View):
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
@ -573,13 +574,13 @@ class MailingAutoGenerationView(View):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
club = self.mailing.club
|
club = self.mailing.club
|
||||||
already_subscribed = [sub.user for sub in self.mailing.subscriptions.all()]
|
self.mailing.subscriptions.all().delete()
|
||||||
members = club.members.filter(role__gte=settings.SITH_CLUB_ROLES_ID['Board member'])
|
members = club.members.filter(role__gte=settings.SITH_CLUB_ROLES_ID['Board member']).exclude(end_date__lte=timezone.now())
|
||||||
members = members.exclude(user__in=already_subscribed)
|
|
||||||
for member in members.all():
|
for member in members.all():
|
||||||
MailingSubscription(user=member.user, mailing=self.mailing).save()
|
MailingSubscription(user=member.user, mailing=self.mailing).save()
|
||||||
return redirect('club:mailing', club_id=club.id)
|
return redirect('club:mailing', club_id=club.id)
|
||||||
|
|
||||||
|
|
||||||
class MailingAutoCleanView(View):
|
class MailingAutoCleanView(View):
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
@ -589,6 +590,5 @@ class MailingAutoCleanView(View):
|
|||||||
return super(MailingAutoCleanView, self).dispatch(request, *args, **kwargs)
|
return super(MailingAutoCleanView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
for sub in self.mailing.subscriptions.all():
|
self.mailing.subscriptions.all().delete()
|
||||||
sub.delete()
|
|
||||||
return redirect('club:mailing', club_id=self.mailing.club.id)
|
return redirect('club:mailing', club_id=self.mailing.club.id)
|
||||||
|
@ -1226,7 +1226,6 @@ label {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#club_detail {
|
#club_detail {
|
||||||
|
|
||||||
.club_logo {
|
.club_logo {
|
||||||
float: right;
|
float: right;
|
||||||
img {
|
img {
|
||||||
|
Loading…
Reference in New Issue
Block a user