From 06268041c1551b86c5f2d0696652d8c13b88b931 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 19 Jun 2012 16:57:08 +0200 Subject: [PATCH] Various changes: * Updated *Settings* section * Users can now change their first/last name (see #268) * *admin* and *userprefs* templates moved to their respective application folders (see #245) --- .../templates}/admin/dlistform.html | 0 .../templates}/admin/domain_general_form.html | 0 .../templates}/admin/domains.html | 0 .../templates}/admin/editdomainform.html | 0 .../templates}/admin/extensions.html | 0 .../templates}/admin/header.html | 0 .../templates}/admin/identities.html | 0 .../templates}/admin/import_done.html | 0 .../templates}/admin/importform.html | 0 .../templates}/admin/listing.html | 0 .../templates}/admin/mailboxes_raw.html | 0 .../templates}/admin/mailform.html | 0 .../templates}/admin/newaccount.html | 0 .../templates}/admin/newdomainform.html | 0 .../templates}/admin/parameters.html | 0 .../templates}/admin/permsform.html | 0 .../templates}/admin/searchform.html | 0 .../templates}/admin/settings_header.html | 0 admin/views.py | 2 +- extensions/amavis_quarantine/sql_listing.py | 2 +- extensions/postfix_autoreply/__init__.py | 24 +--- extensions/postfix_autoreply/models.py | 4 +- .../postfix_autoreply/autoreply.html | 20 ++++ extensions/postfix_autoreply/views.py | 29 +++-- lib/templatetags/libextras.py | 4 +- static/css/custom.css | 3 +- static/js/global.js | 1 + templates/common/generic_field.html | 3 +- urls.py | 5 - userprefs/__init__.py | 13 -- userprefs/forms.py | 37 ++++-- userprefs/templates/userprefs/form.html | 5 + .../templates}/userprefs/preferences.html | 18 +-- userprefs/templates/userprefs/section.html | 27 +++++ userprefs/templatetags/uprefs_extras.py | 28 ++--- userprefs/urls.py | 5 +- userprefs/views.py | 113 ++++++++---------- 37 files changed, 176 insertions(+), 167 deletions(-) rename {templates => admin/templates}/admin/dlistform.html (100%) rename {templates => admin/templates}/admin/domain_general_form.html (100%) rename {templates => admin/templates}/admin/domains.html (100%) rename {templates => admin/templates}/admin/editdomainform.html (100%) rename {templates => admin/templates}/admin/extensions.html (100%) rename {templates => admin/templates}/admin/header.html (100%) rename {templates => admin/templates}/admin/identities.html (100%) rename {templates => admin/templates}/admin/import_done.html (100%) rename {templates => admin/templates}/admin/importform.html (100%) rename {templates => admin/templates}/admin/listing.html (100%) rename {templates => admin/templates}/admin/mailboxes_raw.html (100%) rename {templates => admin/templates}/admin/mailform.html (100%) rename {templates => admin/templates}/admin/newaccount.html (100%) rename {templates => admin/templates}/admin/newdomainform.html (100%) rename {templates => admin/templates}/admin/parameters.html (100%) rename {templates => admin/templates}/admin/permsform.html (100%) rename {templates => admin/templates}/admin/searchform.html (100%) rename {templates => admin/templates}/admin/settings_header.html (100%) create mode 100644 extensions/postfix_autoreply/templates/postfix_autoreply/autoreply.html create mode 100644 userprefs/templates/userprefs/form.html rename {templates => userprefs/templates}/userprefs/preferences.html (67%) create mode 100644 userprefs/templates/userprefs/section.html diff --git a/templates/admin/dlistform.html b/admin/templates/admin/dlistform.html similarity index 100% rename from templates/admin/dlistform.html rename to admin/templates/admin/dlistform.html diff --git a/templates/admin/domain_general_form.html b/admin/templates/admin/domain_general_form.html similarity index 100% rename from templates/admin/domain_general_form.html rename to admin/templates/admin/domain_general_form.html diff --git a/templates/admin/domains.html b/admin/templates/admin/domains.html similarity index 100% rename from templates/admin/domains.html rename to admin/templates/admin/domains.html diff --git a/templates/admin/editdomainform.html b/admin/templates/admin/editdomainform.html similarity index 100% rename from templates/admin/editdomainform.html rename to admin/templates/admin/editdomainform.html diff --git a/templates/admin/extensions.html b/admin/templates/admin/extensions.html similarity index 100% rename from templates/admin/extensions.html rename to admin/templates/admin/extensions.html diff --git a/templates/admin/header.html b/admin/templates/admin/header.html similarity index 100% rename from templates/admin/header.html rename to admin/templates/admin/header.html diff --git a/templates/admin/identities.html b/admin/templates/admin/identities.html similarity index 100% rename from templates/admin/identities.html rename to admin/templates/admin/identities.html diff --git a/templates/admin/import_done.html b/admin/templates/admin/import_done.html similarity index 100% rename from templates/admin/import_done.html rename to admin/templates/admin/import_done.html diff --git a/templates/admin/importform.html b/admin/templates/admin/importform.html similarity index 100% rename from templates/admin/importform.html rename to admin/templates/admin/importform.html diff --git a/templates/admin/listing.html b/admin/templates/admin/listing.html similarity index 100% rename from templates/admin/listing.html rename to admin/templates/admin/listing.html diff --git a/templates/admin/mailboxes_raw.html b/admin/templates/admin/mailboxes_raw.html similarity index 100% rename from templates/admin/mailboxes_raw.html rename to admin/templates/admin/mailboxes_raw.html diff --git a/templates/admin/mailform.html b/admin/templates/admin/mailform.html similarity index 100% rename from templates/admin/mailform.html rename to admin/templates/admin/mailform.html diff --git a/templates/admin/newaccount.html b/admin/templates/admin/newaccount.html similarity index 100% rename from templates/admin/newaccount.html rename to admin/templates/admin/newaccount.html diff --git a/templates/admin/newdomainform.html b/admin/templates/admin/newdomainform.html similarity index 100% rename from templates/admin/newdomainform.html rename to admin/templates/admin/newdomainform.html diff --git a/templates/admin/parameters.html b/admin/templates/admin/parameters.html similarity index 100% rename from templates/admin/parameters.html rename to admin/templates/admin/parameters.html diff --git a/templates/admin/permsform.html b/admin/templates/admin/permsform.html similarity index 100% rename from templates/admin/permsform.html rename to admin/templates/admin/permsform.html diff --git a/templates/admin/searchform.html b/admin/templates/admin/searchform.html similarity index 100% rename from templates/admin/searchform.html rename to admin/templates/admin/searchform.html diff --git a/templates/admin/settings_header.html b/admin/templates/admin/settings_header.html similarity index 100% rename from templates/admin/settings_header.html rename to admin/templates/admin/settings_header.html diff --git a/admin/views.py b/admin/views.py index a598cbb8f..da0b7ec3b 100644 --- a/admin/views.py +++ b/admin/views.py @@ -27,7 +27,7 @@ def domains(request): if request.user.has_perm("admin.view_mailboxes"): return HttpResponseRedirect(reverse(identities)) - return HttpResponseRedirect(reverse(userprefs.views.preferences)) + return HttpResponseRedirect(reverse(userprefs.views.index)) domains = request.user.get_domains() squery = request.GET.get("searchquery", None) diff --git a/extensions/amavis_quarantine/sql_listing.py b/extensions/amavis_quarantine/sql_listing.py index 587bca248..776d9269b 100644 --- a/extensions/amavis_quarantine/sql_listing.py +++ b/extensions/amavis_quarantine/sql_listing.py @@ -81,7 +81,7 @@ class SQLconnector(MBconnector): return emails class SQLlisting(EmailListing): - tpl = "amavis_quarantine/index2.html" + tpl = "amavis_quarantine/index.html" tbltype = Qtable deflocation = "listing/" defcallback = "updatelisting" diff --git a/extensions/postfix_autoreply/__init__.py b/extensions/postfix_autoreply/__init__.py index 4b6a22510..33d762cee 100644 --- a/extensions/postfix_autoreply/__init__.py +++ b/extensions/postfix_autoreply/__init__.py @@ -8,7 +8,7 @@ functionality into Postfix. """ from django.conf.urls.defaults import include from django.core.urlresolvers import reverse -from django.utils.translation import ugettext as _, ugettext_lazy, get_language +from django.utils.translation import ugettext as _, ugettext_lazy from modoboa.lib import events, parameters from modoboa.extensions import ModoExtension, exts_pool from models import * @@ -65,9 +65,7 @@ def menu(target, user): return [ {"name" : "autoreply", "url" : reverse(views.autoreply), - "label" : ugettext_lazy("Auto-reply message"), - "modal": True, - "modalcb" : "arform_cb"} + "label" : ugettext_lazy("Auto-reply message")} ] @events.observe("CreateDomain") @@ -113,21 +111,3 @@ def onModifyMailbox(mailbox, oldmailbox): alias.autoreply_address = \ "%s@autoreply.%s" % (mailbox.full_address, mailbox.domain.name) alias.save() - -@events.observe("GetStaticContent") -def get_static_content(user): - if not user.has_mailbox: - return [] - - return """ -""" % get_language() diff --git a/extensions/postfix_autoreply/models.py b/extensions/postfix_autoreply/models.py index 110d37aca..5381f6a19 100644 --- a/extensions/postfix_autoreply/models.py +++ b/extensions/postfix_autoreply/models.py @@ -13,9 +13,9 @@ class Alias(models.Model): class ARmessage(models.Model): mbox = models.ForeignKey(Mailbox) subject = models.CharField(_('subject'), max_length=255, - help_text=_("The subject that will appear in sended emails")) + help_text=_("The subject that will appear in sent emails")) content = models.TextField(_('content'), - help_text=_("The content that will appear in sended emails")) + help_text=_("The content that will appear in sent emails")) enabled = models.BooleanField(_('enabled'), help_text=_("Activate/Deactivate your auto reply")) untildate = models.DateField() diff --git a/extensions/postfix_autoreply/templates/postfix_autoreply/autoreply.html b/extensions/postfix_autoreply/templates/postfix_autoreply/autoreply.html new file mode 100644 index 000000000..4130eec0c --- /dev/null +++ b/extensions/postfix_autoreply/templates/postfix_autoreply/autoreply.html @@ -0,0 +1,20 @@ +{% extends "userprefs/section.html" %} +{% block html_head %} + +{% endblock %} diff --git a/extensions/postfix_autoreply/views.py b/extensions/postfix_autoreply/views.py index 62dd4078e..0caa624ff 100644 --- a/extensions/postfix_autoreply/views.py +++ b/extensions/postfix_autoreply/views.py @@ -7,21 +7,14 @@ from django.contrib.auth.decorators \ from django.contrib import messages from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ -from modoboa.lib.webutils import _render, ajax_response +from modoboa.lib.webutils import _render, ajax_simple_response, ajax_response from modoboa.lib.decorators import needs_mailbox from forms import * from models import * @login_required @needs_mailbox() -def autoreply(request, tplname="common/generic_modal_form.html"): - ctx = dict( - title=_("Auto-reply message"), - action=reverse(autoreply), - formid="arform", - action_label=_("Update"), - action_classes="submit" - ) +def autoreply(request, tplname="userprefs/section.html"): mb = Mailbox.objects.get(user=request.user.id) try: arm = ARmessage.objects.get(mbox=mb.id) @@ -32,7 +25,6 @@ def autoreply(request, tplname="common/generic_modal_form.html"): form = ARmessageForm(request.POST, instance=arm) else: form = ARmessageForm(request.POST) - error = None if form.is_valid(): from modoboa import userprefs @@ -40,15 +32,22 @@ def autoreply(request, tplname="common/generic_modal_form.html"): arm.untildate = form.cleaned_data["untildate"] arm.mbox = mb arm.save() - messages.info(request, _("Auto reply message updated successfully.")) - return ajax_response(request, url=reverse(userprefs.views.index)) - ctx.update(form=form, error=error) - return ajax_response(request, status="ko", template=tplname, **ctx) + return ajax_simple_response(dict( + status="ok", respmsg=_("Auto reply message updated successfully.") + )) + return ajax_response(request, status="ko", template="userprefs/form.html", form=form) + + ctx = dict( + title=_("Auto-reply message"), + subtitle=_("Define an automatic message to send when you are unavailable"), + action=reverse(autoreply), + left_selection="autoreply", + ) form = ARmessageForm(instance=arm) if arm is not None: form.fields['untildate'].initial = arm.untildate else: form.fields['untildate'].initial = date.today() ctx.update(form=form) - return _render(request, tplname, ctx) + return _render(request, "postfix_autoreply/autoreply.html", ctx) diff --git a/lib/templatetags/libextras.py b/lib/templatetags/libextras.py index 5d4fb3a91..b2d6a7ecc 100644 --- a/lib/templatetags/libextras.py +++ b/lib/templatetags/libextras.py @@ -94,9 +94,9 @@ def render_form(form, tpl=None): return ret @register.simple_tag -def render_field(field): +def render_field(field, help_display_mode="tooltip"): return render_to_string("common/generic_field.html", dict( - field=field + field=field, help_display_mode=help_display_mode )) @register.simple_tag diff --git a/static/css/custom.css b/static/css/custom.css index 470b3001e..108198a73 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -62,7 +62,8 @@ body { } .spaced select, -.spaced input[type="text"] { +.spaced input[type="text"], +.spaced input[type="password"] { margin-bottom: 8px; } diff --git a/static/js/global.js b/static/js/global.js index 021e4ccc1..a1f50c69c 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -226,4 +226,5 @@ $(document).ready(function() { $(document).ajaxSuccess(function(e, xhr, settings) { ajax_login_redirect(xhr); }); $(document).on('click', 'a[data-toggle="ajaxmodal"]', modalbox); $(document).on('click', 'a[data-toggle="ajaxmodal-autowidth"]', modalbox_autowidth); + $(".help").popover(); }); \ No newline at end of file diff --git a/templates/common/generic_field.html b/templates/common/generic_field.html index f0d21c98f..20cd257da 100644 --- a/templates/common/generic_field.html +++ b/templates/common/generic_field.html @@ -1,7 +1,6 @@ {% load i18n %}