Commit 168622a0 authored by Skia's avatar Skia

Add com app with first parametric texts

parent 13785fd5
Pipeline #567 passed with stage
in 2 minutes and 33 seconds
from django.contrib import admin
from com.models import *
admin.site.register(Sith)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Sith',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
('alert_msg', models.TextField(default='', verbose_name='alert message', blank=True)),
('info_msg', models.TextField(default='', verbose_name='info message', blank=True)),
('index_page', models.TextField(default='', verbose_name='index page', blank=True)),
],
),
]
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
class Sith(models.Model):
alert_msg = models.TextField(_("alert message"), default="", blank=True)
info_msg = models.TextField(_("info message"), default="", blank=True)
index_page = models.TextField(_("index page"), default="", blank=True)
def is_owned_by(self, user):
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
def __str__(self):
return "⛩ Sith ⛩"
from django.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
from django.core.management import call_command
from core.models import User, RealGroup
from com.models import Sith
class ComTest(TestCase):
def setUp(self):
call_command("populate")
self.skia = User.objects.filter(username="skia").first()
self.com_group = RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID).first()
self.skia.groups = [self.com_group]
self.skia.save()
self.client.login(username=self.skia.username, password='plop')
def test_alert_msg(self):
response = self.client.post(reverse("com:alert_edit"), {"alert_msg": """
### ALERTE!
**Caaaataaaapuuuulte!!!!**
"""})
r = self.client.get(reverse("core:index"))
self.assertTrue(r.status_code == 200)
self.assertTrue("""<div id="alert_box">\\n <h3>ALERTE!</h3>\\n<p><strong>Caaaataaaapuuuulte!!!!</strong></p>""" in str(r.content))
def test_info_msg(self):
response = self.client.post(reverse("com:info_edit"), {"info_msg": """
### INFO: **Caaaataaaapuuuulte!!!!**
"""})
r = self.client.get(reverse("core:index"))
self.assertTrue(r.status_code == 200)
self.assertTrue("""<div id="info_box">\\n <h3>INFO: <strong>Caaaataaaapuuuulte!!!!</strong></h3>""" in str(r.content))
from django.conf.urls import url, include
from com.views import *
urlpatterns = [
url(r'^edit/alert$', AlertMsgEditView.as_view(), name='alert_edit'),
url(r'^edit/info$', InfoMsgEditView.as_view(), name='info_edit'),
url(r'^edit/index$', IndexEditView.as_view(), name='index_edit'),
]
from django.shortcuts import render
from django.views.generic.edit import UpdateView
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse, reverse_lazy
from com.models import Sith
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
sith = Sith.objects.first
class ComTabsMixin(TabedViewMixin):
def get_tabs_title(self):
return _("Communication administration")
def get_list_of_tabs(self):
tab_list = []
tab_list.append({
'url': reverse('com:index_edit'),
'slug': 'index',
'name': _("Index page"),
})
tab_list.append({
'url': reverse('com:info_edit'),
'slug': 'info',
'name': _("Info message"),
})
tab_list.append({
'url': reverse('com:alert_edit'),
'slug': 'alert',
'name': _("Alert message"),
})
return tab_list
class ComEditView(ComTabsMixin, CanEditPropMixin, UpdateView):
model = Sith
template_name = 'core/edit.jinja'
def get_object(self, queryset=None):
return Sith.objects.first()
class AlertMsgEditView(ComEditView):
fields = ['alert_msg']
current_tab = "alert"
success_url = reverse_lazy('com:alert_edit')
class InfoMsgEditView(ComEditView):
fields = ['info_msg']
current_tab = "info"
success_url = reverse_lazy('com:info_edit')
class IndexEditView(ComEditView):
fields = ['index_page']
current_tab = "index"
success_url = reverse_lazy('com:index_edit')
...@@ -14,6 +14,7 @@ from accounting.models import GeneralJournal, BankAccount, ClubAccount, Operatio ...@@ -14,6 +14,7 @@ from accounting.models import GeneralJournal, BankAccount, ClubAccount, Operatio
from club.models import Club, Membership from club.models import Club, Membership
from subscription.models import Subscription from subscription.models import Subscription
from counter.models import Customer, ProductType, Product, Counter from counter.models import Customer, ProductType, Product, Counter
from com.models import Sith
class Command(BaseCommand): class Command(BaseCommand):
help = "Populate a new instance of the Sith AE" help = "Populate a new instance of the Sith AE"
...@@ -80,6 +81,8 @@ class Command(BaseCommand): ...@@ -80,6 +81,8 @@ class Command(BaseCommand):
home_root.save() home_root.save()
club_root.save() club_root.save()
Sith().save()
p = Page(name='Index') p = Page(name='Index')
p.set_lock(root) p.set_lock(root)
p.save() p.save()
......
...@@ -4,7 +4,7 @@ html, body, div, span, applet, object, iframe, ...@@ -4,7 +4,7 @@ html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code, a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp, del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var, small, strike, sub, sup, tt, var,
b, u, i, center, b, u, i, center,
dl, dt, dd, ol, ul, li, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, fieldset, form, label, legend,
......
...@@ -14,6 +14,7 @@ a:active { color: #007BE6; } ...@@ -14,6 +14,7 @@ a:active { color: #007BE6; }
/*--------------------------------HEADER-------------------------------*/ /*--------------------------------HEADER-------------------------------*/
#logo { #logo {
margin-left: 5%; margin-left: 5%;
display: inline-block;
} }
header { header {
display: block; display: block;
...@@ -75,6 +76,29 @@ header form { ...@@ -75,6 +76,29 @@ header form {
background: #bcc; background: #bcc;
} }
#alert_box p, #info_box p {
margin: 0px;
padding: 0px;
}
#alert_box, #info_box {
font-size: smaller;
display: inline-block;
border: solid 1px grey;
vertical-align: top;
padding: 2px;
margin: 4px;
margin-top: 60px;
min-width: 10%;
max-width: 30%;
min-height: 20px;
}
#info_box {
background: cornsilk
}
#alert_box {
background: gold;
}
/*---------------------------------NAV---------------------------------*/ /*---------------------------------NAV---------------------------------*/
nav { nav {
display: block; display: block;
......
...@@ -17,6 +17,17 @@ ...@@ -17,6 +17,17 @@
{% if not popup %} {% if not popup %}
<div id="logo"><a href="{{ url('core:index') }}"><img src="{{ static('core/img/logo.png') }}" <div id="logo"><a href="{{ url('core:index') }}"><img src="{{ static('core/img/logo.png') }}"
alt="{% trans %}Logo{% endtrans %}" /></a></div> alt="{% trans %}Logo{% endtrans %}" /></a></div>
{% set sith = get_sith() %}
{% if sith.alert_msg %}
<div id="alert_box">
{{ sith.alert_msg|markdown }}
</div>
{% endif %}
{% if sith.info_msg %}
<div id="info_box">
{{ sith.info_msg|markdown }}
</div>
{% endif %}
<header> <header>
{% if not user.is_authenticated() %} {% if not user.is_authenticated() %}
<a href="{{ url('core:login') }}">{% trans %}Login{% endtrans %}</a> <a href="{{ url('core:login') }}">{% trans %}Login{% endtrans %}</a>
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
{% block title %} {% block title %}
{% trans %}Welcome!{% endtrans %} {% trans %}Welcome!{% endtrans %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<p>{% trans %}Welcome to the new AE's website!{% endtrans %}</p> {{ get_sith().index_page|markdown }}
<p>Ce site supporte pour l'instant toute la gestion de l'argent, c'est à dire les comptes AE, les comptoirs,
l'Eboutic, et la comptabilité</p>
<p>Pour le reste, merci de retourner voir sur l'<a href="https://ae.utbm.fr">ancien site</a></p>
{% endblock %} {% endblock %}
...@@ -65,7 +65,10 @@ ...@@ -65,7 +65,10 @@
<hr> <hr>
<h4>{% trans %}Communication{% endtrans %}</h4> <h4>{% trans %}Communication{% endtrans %}</h4>
<ul> <ul>
{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %} {% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %}
<li><a href="{{ url('com:index_edit') }}">{% trans %}Edit index page{% endtrans %}</a></li>
<li><a href="{{ url('com:alert_edit') }}">{% trans %}Edit alert message{% endtrans %}</a></li>
<li><a href="{{ url('com:info_edit') }}">{% trans %}Edit information message{% endtrans %}</a></li>
<li><a href="{{ url('core:file_moderation') }}">{% trans %}Moderate files{% endtrans %}</a></li> <li><a href="{{ url('core:file_moderation') }}">{% trans %}Moderate files{% endtrans %}</a></li>
{% endif %} {% endif %}
{% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %} {% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-20 12:24+0100\n" "POT-Creation-Date: 2016-12-21 02:37+0100\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
...@@ -85,12 +85,12 @@ msgstr "Compte club" ...@@ -85,12 +85,12 @@ msgstr "Compte club"
msgid "%(club_account)s on %(bank_account)s" msgid "%(club_account)s on %(bank_account)s"
msgstr "%(club_account)s sur %(bank_account)s" msgstr "%(club_account)s sur %(bank_account)s"
#: accounting/models.py:142 club/models.py:146 counter/models.py:398 #: accounting/models.py:142 club/models.py:146 counter/models.py:399
#: launderette/models.py:120 #: launderette/models.py:120
msgid "start date" msgid "start date"
msgstr "date de début" msgstr "date de début"
#: accounting/models.py:143 club/models.py:147 counter/models.py:399 #: accounting/models.py:143 club/models.py:147 counter/models.py:400
msgid "end date" msgid "end date"
msgstr "date de fin" msgstr "date de fin"
...@@ -123,13 +123,13 @@ msgstr "numéro" ...@@ -123,13 +123,13 @@ msgstr "numéro"
msgid "journal" msgid "journal"
msgstr "classeur" msgstr "classeur"
#: accounting/models.py:194 core/models.py:530 core/models.py:876 #: accounting/models.py:194 core/models.py:530 core/models.py:875
#: core/models.py:916 counter/models.py:242 counter/models.py:290 #: core/models.py:915 counter/models.py:242 counter/models.py:290
#: counter/models.py:415 eboutic/models.py:15 eboutic/models.py:48 #: counter/models.py:416 eboutic/models.py:15 eboutic/models.py:48
msgid "date" msgid "date"
msgstr "date" msgstr "date"
#: accounting/models.py:195 counter/models.py:416 #: accounting/models.py:195 counter/models.py:417
msgid "comment" msgid "comment"
msgstr "commentaire" msgstr "commentaire"
...@@ -190,7 +190,7 @@ msgstr "Compte" ...@@ -190,7 +190,7 @@ msgstr "Compte"
msgid "Company" msgid "Company"
msgstr "Entreprise" msgstr "Entreprise"
#: accounting/models.py:207 sith/settings.py:286 #: accounting/models.py:207 sith/settings.py:296
msgid "Other" msgid "Other"
msgstr "Autre" msgstr "Autre"
...@@ -678,7 +678,7 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs" ...@@ -678,7 +678,7 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs"
msgid "A club with that unix_name already exists" msgid "A club with that unix_name already exists"
msgstr "Un club avec ce nom UNIX existe déjà." msgstr "Un club avec ce nom UNIX existe déjà."
#: club/models.py:144 counter/models.py:396 counter/models.py:413 #: club/models.py:144 counter/models.py:397 counter/models.py:414
#: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:87 #: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:87
#: launderette/models.py:124 sas/models.py:131 #: launderette/models.py:124 sas/models.py:131
msgid "user" msgid "user"
...@@ -844,7 +844,7 @@ msgid "Payment method" ...@@ -844,7 +844,7 @@ msgid "Payment method"
msgstr "Méthode de paiement" msgstr "Méthode de paiement"
#: club/templates/club/club_tools.jinja:4 #: club/templates/club/club_tools.jinja:4
#: core/templates/core/user_tools.jinja:78 #: core/templates/core/user_tools.jinja:81
msgid "Club tools" msgid "Club tools"
msgstr "Outils club" msgstr "Outils club"
...@@ -868,7 +868,7 @@ msgstr "Membres" ...@@ -868,7 +868,7 @@ msgstr "Membres"
msgid "Old members" msgid "Old members"
msgstr "Anciens membres" msgstr "Anciens membres"
#: club/views.py:49 core/templates/core/base.jinja:53 core/views/user.py:146 #: club/views.py:49 core/templates/core/base.jinja:64 core/views/user.py:146
#: sas/templates/sas/picture.jinja:87 #: sas/templates/sas/picture.jinja:87
msgid "Tools" msgid "Tools"
msgstr "Outils" msgstr "Outils"
...@@ -900,6 +900,34 @@ msgstr "Date de fin" ...@@ -900,6 +900,34 @@ msgstr "Date de fin"
msgid "Product" msgid "Product"
msgstr "Produit" msgstr "Produit"
#: com/models.py:6
msgid "alert message"
msgstr "message d'alerte"
#: com/models.py:7
msgid "info message"
msgstr "message d'info"
#: com/models.py:8
msgid "index page"
msgstr "page d'accueil"
#: com/views.py:14
msgid "Communication administration"
msgstr "Administration de la communication"
#: com/views.py:21
msgid "Index page"
msgstr "Page d'accueil"
#: com/views.py:26
msgid "Info message"
msgstr "Message d'info"
#: com/views.py:31
msgid "Alert message"
msgstr "Message d'alerte"
#: core/models.py:29 #: core/models.py:29
msgid "meta group status" msgid "meta group status"
msgstr "status du meta-groupe" msgstr "status du meta-groupe"
...@@ -1202,7 +1230,7 @@ msgstr "Montrez vos statistiques de compte aux autres" ...@@ -1202,7 +1230,7 @@ msgstr "Montrez vos statistiques de compte aux autres"
msgid "file name" msgid "file name"
msgstr "nom du fichier" msgstr "nom du fichier"
#: core/models.py:520 core/models.py:721 #: core/models.py:520 core/models.py:720
msgid "parent" msgid "parent"
msgstr "parent" msgstr "parent"
...@@ -1222,11 +1250,11 @@ msgstr "miniature" ...@@ -1222,11 +1250,11 @@ msgstr "miniature"
msgid "owner" msgid "owner"
msgstr "propriétaire" msgstr "propriétaire"
#: core/models.py:525 core/models.py:727 #: core/models.py:525 core/models.py:726
msgid "edit group" msgid "edit group"
msgstr "groupe d'édition" msgstr "groupe d'édition"
#: core/models.py:526 core/models.py:728 #: core/models.py:526 core/models.py:727
msgid "view group" msgid "view group"
msgstr "groupe de vue" msgstr "groupe de vue"
...@@ -1276,64 +1304,64 @@ msgstr "Un fichier de ce nom existe déjà" ...@@ -1276,64 +1304,64 @@ msgstr "Un fichier de ce nom existe déjà"
msgid "You must provide a file" msgid "You must provide a file"
msgstr "Vous devez fournir un fichier" msgstr "Vous devez fournir un fichier"
#: core/models.py:670 #: core/models.py:669
msgid "Folder: " msgid "Folder: "
msgstr "Dossier : " msgstr "Dossier : "
#: core/models.py:672 #: core/models.py:671
msgid "File: " msgid "File: "
msgstr "Fichier : " msgstr "Fichier : "
#: core/models.py:720 core/models.py:724 #: core/models.py:719 core/models.py:723
msgid "page name" msgid "page name"
msgstr "nom de la page" msgstr "nom de la page"
#: core/models.py:725 #: core/models.py:724
msgid "owner group" msgid "owner group"
msgstr "groupe propriétaire" msgstr "groupe propriétaire"
#: core/models.py:729 #: core/models.py:728
msgid "lock user" msgid "lock user"
msgstr "utilisateur bloquant" msgstr "utilisateur bloquant"
#: core/models.py:730 #: core/models.py:729
msgid "lock_timeout" msgid "lock_timeout"
msgstr "décompte du déblocage" msgstr "décompte du déblocage"
#: core/models.py:757 #: core/models.py:756
msgid "Duplicate page" msgid "Duplicate page"
msgstr "Une page de ce nom existe déjà" msgstr "Une page de ce nom existe déjà"
#: core/models.py:763 #: core/models.py:762
msgid "Loop in page tree" msgid "Loop in page tree"
msgstr "Boucle dans l'arborescence des pages" msgstr "Boucle dans l'arborescence des pages"
#: core/models.py:873 #: core/models.py:872
msgid "revision" msgid "revision"
msgstr "révision" msgstr "révision"
#: core/models.py:874 #: core/models.py:873
msgid "page title" msgid "page title"
msgstr "titre de la page" msgstr "titre de la page"
#: core/models.py:875 #: core/models.py:874
msgid "page content" msgid "page content"
msgstr "contenu de la page" msgstr "contenu de la page"
#: core/models.py:913 #: core/models.py:912
msgid "url" msgid "url"
msgstr "url" msgstr "url"
#: core/models.py:914 #: core/models.py:913
msgid "param" msgid "param"
msgstr "param" msgstr "param"
#: core/models.py:915 launderette/models.py:60 launderette/models.py:85 #: core/models.py:914 launderette/models.py:60 launderette/models.py:85
#: launderette/models.py:121 #: launderette/models.py:121
msgid "type" msgid "type"
msgstr "type" msgstr "type"
#: core/models.py:917 #: core/models.py:916
msgid "viewed" msgid "viewed"
msgstr "vue" msgstr "vue"
...@@ -1353,91 +1381,91 @@ msgstr "Bienvenue!" ...@@ -1353,91 +1381,91 @@ msgstr "Bienvenue!"
msgid "Logo" msgid "Logo"
msgstr "Logo" msgstr "Logo"
#: core/templates/core/base.jinja:22 core/templates/core/login.jinja:4 #: core/templates/core/base.jinja:33 core/templates/core/login.jinja:4
#: core/templates/core/password_reset_complete.jinja:5 #: core/templates/core/password_reset_complete.jinja:5
msgid "Login" msgid "Login"
msgstr "Connexion" msgstr "Connexion"
#: core/templates/core/base.jinja:23 core/templates/core/register.jinja:18 #: core/templates/core/base.jinja:34 core/templates/core/register.jinja:18
msgid "Register" msgid "Register"
msgstr "S'enregister" msgstr "S'enregister"
#: core/templates/core/base.jinja:50 #: core/templates/core/base.jinja:61
msgid "View more" msgid "View more"
msgstr "Voir plus" msgstr "Voir plus"
#: core/templates/core/base.jinja:51 #: core/templates/core/base.jinja:62
msgid "Mark all as read" msgid "Mark all as read"
msgstr "Marquer tout commme lu" msgstr "Marquer tout commme lu"
#: core/templates/core/base.jinja:54 #: core/templates/core/base.jinja:65
msgid "Logout" msgid "Logout"
msgstr "Déconnexion" msgstr "Déconnexion"
#: core/templates/core/base.jinja:56 core/templates/core/base.jinja.py:57