mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Some great weekmail improvements
This commit is contained in:
@ -6,9 +6,9 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>{% trans %}Weekmail{% endtrans %}</h3>
|
||||
<p><a href="{{ url('com:weekmail_preview') }}" target="_blank">{% trans %}Preview{% endtrans %}</a></p>
|
||||
<p><a href="?send">{% trans %}Send{% endtrans %}</a></p>
|
||||
<h3>{% trans %}Weekmail{% endtrans %} {{ object.id }}</h3>
|
||||
<p><a href="{{ url('com:weekmail_preview') }}">{% trans %}Preview{% endtrans %}</a></p>
|
||||
<p><a href="{{ url('com:weekmail_preview') }}?send=true">{% trans %}Send{% endtrans %}</a></p>
|
||||
<h4>{% trans %}Articles in no weekmail yet{% endtrans %}</h4>
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -6,6 +6,18 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<a href="{{ url('com:weekmail') }}">{% trans %}Back{% endtrans %}</a>
|
||||
{% if request.GET['send'] %}
|
||||
<p>{% trans %}Are you sure you want to send this weekmail?{% endtrans %}</p>
|
||||
{% if request.LANGUAGE_CODE != settings.LANGUAGE_CODE[:2] %}
|
||||
<p><strong>{% trans %}Warning: you are sending the weekmail in another language than the default one!{% endtrans %}</strong></p>
|
||||
{% endif %}
|
||||
<form method="post" action="">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="send" value="validate">{% trans %}Send{% endtrans %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<hr>
|
||||
{{ weekmail_rendered|safe }}
|
||||
{% endblock %}
|
||||
|
||||
|
16
com/views.py
16
com/views.py
@ -1,4 +1,5 @@
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.views.generic import ListView, DetailView, RedirectView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
@ -231,10 +232,20 @@ class NewsDetailView(CanViewMixin, DetailView):
|
||||
|
||||
# Weekmail
|
||||
|
||||
class WeekmailPreviewView(DetailView):
|
||||
class WeekmailPreviewView(ComTabsMixin, DetailView):
|
||||
model = Weekmail
|
||||
template_name = 'com/weekmail_preview.jinja'
|
||||
success_url = reverse_lazy('com:weekmail')
|
||||
current_tab = "weekmail"
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
try:
|
||||
if request.POST['send'] == "validate":
|
||||
self.object.send()
|
||||
return HttpResponseRedirect(reverse('com:weekmail') + "?qn_weekmail_send_success")
|
||||
except: pass
|
||||
return super(WeekmailEditView, self).get(request, *args, **kwargs)
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
return self.model.objects.filter(sent=False).order_by('-id').first()
|
||||
@ -291,9 +302,6 @@ class WeekmailEditView(ComTabsMixin, QuickNotifMixin, UpdateView):
|
||||
art.rank = -1
|
||||
art.save()
|
||||
self.quick_notif_list += ['qn_success']
|
||||
if 'send' in request.GET.keys():
|
||||
self.object.send()
|
||||
self.quick_notif_list += ['qn_success']
|
||||
return super(WeekmailEditView, self).get(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
Reference in New Issue
Block a user