If the demo application is activated, an announcement now appears on the login page to inform visitors on how to use the demo.

This commit is contained in:
Antoine Nguyen
2011-11-18 23:42:31 +01:00
parent efc024ad93
commit d23923a248
8 changed files with 83 additions and 27 deletions
+3 -1
View File
@@ -39,9 +39,11 @@ def dologin(request):
error = _("Your username and password didn't match. Please try again.")
else:
form = LoginForm()
next = request.GET.has_key("next") and request.GET["next"] or None
return render_to_response("registration/login.html", {
"form" : form, "error" : error, "next" : next
"form" : form, "error" : error, "next" : next,
"annoucements" : events.raiseQueryEvent("GetAnnouncement", target="loginpage")
}, context_instance=RequestContext(request))
def dologout(request):
+8
View File
@@ -2,6 +2,7 @@
from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_noop as _
from django.template.loader import render_to_string
from modoboa.lib import events
from modoboa.lib.webutils import static_url
@@ -28,5 +29,12 @@ def menu(**kwargs):
}
]
def announcement(**kwargs):
if kwargs["target"] == "loginpage":
txt = render_to_string("demo/login_announcement.html")
return [txt]
return ""
if 'modoboa.demo' in settings.INSTALLED_APPS:
events.register("UserMenuDisplay", menu)
events.register("GetAnnouncement", announcement)
@@ -0,0 +1,13 @@
{% load i18n %}
{% blocktrans %}
<h1>Welcome to the online demo!</h1>
<p><b>Warning:</b> the demo's concent is resetted every two hours.</p>
<p>To try the demo, the following users are available (<i>username/password</i>): </p>
<ul>
<li>A super administrator : <b>admin/password</b></li>
<li>A domain administrator : <b>admin@demo.local/admin</b></li>
<li>A simple user : <b>user@demo.local/user</b></li>
</ul>
<p>Please report any issue of give any suggestion to
<a href="https://groups.google.com/forum/#!forum/modoboa-users">the mailing list</a>.</p>
{% endblocktrans %}
+12 -1
View File
@@ -126,7 +126,7 @@ that corresponds to the ``Request`` object used inside the associated
view function.
UserLogout
__________
----------
Raised when a user logs out. This event provides a ``request`` argument
that corresponds to the ``Request`` object used inside the associated
@@ -245,6 +245,17 @@ ExtDisabled
Raised just after an extension has been disabled. The Extension
object is available inside the ``ext`` keyword argument.
GetAnnouncement
---------------
Some places in the interface let plugins add their own announcement
(ie. message). A keyword argument ``target`` is provided to registered
callbacks and indicates the place where the announcement will appear:
* ``loginpage`` : corresponds to the login page
Callbacks listening to this event must return a list of string.
Parameters
==========
+1 -1
View File
@@ -3,7 +3,7 @@
import os
import time
import datetime
import rrdtool
#import rrdtool
from django.utils.translation import ugettext as _
from modoboa.lib import parameters
+3 -1
View File
@@ -22,7 +22,9 @@ events = ["CreateDomain",
"ExtDisabled",
"UserLogin",
"UserLogout"]
"UserLogout",
"GetAnnouncement"]
callbacks = {}
+38 -20
View File
@@ -7,26 +7,10 @@ html, body {
}
#loginbox {
margin: 100px auto;
width: 610px;
padding-bottom: 15px;
background: white;
border: 5px solid #333;
/*-moz-box-shadow: 0 10px 30px #222;*/
-webkit-box-shadow: 0 10px 30px #222;
-moz-border-radius: 10px;
-webkit-border-radius: 5px;
}
#loginbox h2 {
margin: 30px 10px 0 10px;
font-size: small;
}
#loginbox h3 {
font-size: small;
text-align: center;
margin: 100px auto 10px auto;
padding: 0 0 15px 0;
font-size: 1em;
width: 630px;
}
#logo {
@@ -46,6 +30,40 @@ html, body {
width: 300px;
}
.roundedbox {
margin: 10px auto;
padding: 10px;
width: 610px;
background: white;
font-size: 1.1em;
border: 5px solid #333;
border-radius: 10px;
}
.roundedbox h1 {
padding: 0;
margin: 0;
font-size: 1.2em;
text-align: center;
}
.roundedbox h2 {
margin: 30px 10px 0 10px;
font-size: small;
}
.roundedbox h3 {
font-size: small;
text-align: center;
}
.roundedbox a, a:visited {
font-weight: bold;
color: black;
text-decoration: none;
}
.spacer {
clear: both;
}
+5 -3
View File
@@ -16,7 +16,7 @@
</head>
<body>
<div id="loginbox">
<div id="loginbox" class="roundedbox">
<div id="logo">
<img src="{{ MEDIA_URL }}css/modoboa.png" />
{% if error %}
@@ -27,8 +27,7 @@
<div id="test">
<h3>{% trans "Welcome" %}</h3>
<form method="post" action="">
{% include "common/genericform.html" %}
{% include "common/genericform.html" %}
<div class="lastrow" align="center">
<input type="submit" value="login" />
</div>
@@ -37,5 +36,8 @@
</div>
<div class="spacer"></div>
</div>
{% for annoucement in annoucements %}
<div class="roundedbox">{{ annoucement|safe }}</div>
{% endfor %}
</body>
</html>