Add quick notifications prototype

This commit is contained in:
Skia 2017-01-07 15:07:28 +01:00
parent 9d1eaed625
commit 0aef7656b8
5 changed files with 53 additions and 0 deletions

View File

@ -35,6 +35,9 @@ $( function() {
popup.html('<iframe src="/file/popup" width="100%" height="95%"></iframe><div id="file_id" value="null" />');
popup.dialog({title: $(this).text()}).dialog( "open" );
});
$("#quick_notif li").click(function () {
$(this).hide();
})
} );
function display_notif() {

View File

@ -122,6 +122,15 @@ nav a:hover {
}
/*--------------------------------CONTENT------------------------------*/
#quick_notif {
width: 90%;
margin: 0px auto;
list-style-type: none;
background: lightblue;
}
#quick_notif li {
padding: 10px;
}
#content {
width: 88%;
margin: 0px auto;

View File

@ -100,6 +100,12 @@
{% endif %}
{% endblock %}
<ul id="quick_notif">
{% for n in quick_notifs %}
<li>{{ n }}</li>
{% endfor %}
</ul>
<div id="content">
{% if list_of_tabs %}
<div class="tool-bar">

View File

@ -147,6 +147,34 @@ class TabedViewMixin(View):
kwargs['list_of_tabs'] = self.get_list_of_tabs()
return kwargs
class QuickNotifMixin():
quick_notif_list = []
def get_success_url(self):
ret = super(QuickNotifMixin, self).get_success_url()
try:
if '?' in ret:
ret += '&' + self.quick_notif_url_arg
else:
ret += '?' + self.quick_notif_url_arg
except: pass
return ret
def get_context_data(self, **kwargs):
"""Add quick notifications to context"""
kwargs = super(QuickNotifMixin, self).get_context_data(**kwargs)
kwargs['quick_notifs'] = []
print(self.quick_notif_list)
for n in self.quick_notif_list:
kwargs['quick_notifs'].append(settings.SITH_QUICK_NOTIF[n])
self.quick_notif_list = [] # In some cases, the class can stay instanciated, so we need to reset the list
for k,v in settings.SITH_QUICK_NOTIF.items():
for gk in self.request.GET.keys():
if k == gk:
kwargs['quick_notifs'].append(v)
print(self.quick_notif_list)
return kwargs
from .user import *
from .page import *
from .files import *

View File

@ -466,6 +466,13 @@ SITH_NOTIFICATIONS = [
('GENERIC', _("You have a notification")),
]
SITH_QUICK_NOTIF = {
'qn_success': _("Success!"),
'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"),
}
try:
from .settings_custom import *
print("Custom settings imported")