Commit 147809bb authored by Skia's avatar Skia

Some great weekmail improvements

parent 83555a36
......@@ -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 %} {{ }}</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>
......@@ -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>
{% endif %}
{{ weekmail_rendered|safe }}
{% endblock %}
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()
if request.POST['send'] == "validate":
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
self.quick_notif_list += ['qn_success']
if 'send' in request.GET.keys():
self.quick_notif_list += ['qn_success']
return super(WeekmailEditView, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
......@@ -17,7 +17,7 @@ from django.utils import timezone
from datetime import timedelta, datetime, date
import logging
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, QuickNotifMixin
from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, LoginForm, UserGodfathersForm
from core.models import User, SithFile, Preferences
from club.models import Club
......@@ -415,7 +415,7 @@ class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
context_object_name = "profile"
current_tab = "groups"
class UserToolsView(UserTabsMixin, TemplateView):
class UserToolsView(QuickNotifMixin, UserTabsMixin, TemplateView):
Displays the logged user's tools
This diff is collapsed.
......@@ -471,6 +471,7 @@ SITH_QUICK_NOTIF = {
'qn_fail': _("Fail!"),
'qn_weekmail_new_article': _("You successfully posted an article in the Weekmail"),
'qn_weekmail_article_edit': _("You successfully edited an article in the Weekmail"),
'qn_weekmail_send_success': _("You successfully sent the Weekmail"),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment