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
from club.models import Club, Membership
from subscription.models import Subscription
from counter.models import Customer, ProductType, Product, Counter
from com.models import Sith
class Command(BaseCommand):
help = "Populate a new instance of the Sith AE"
......@@ -80,6 +81,8 @@ class Command(BaseCommand):
home_root.save()
club_root.save()
Sith().save()
p = Page(name='Index')
p.set_lock(root)
p.save()
......
......@@ -4,13 +4,13 @@ html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
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,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
......@@ -21,7 +21,7 @@ time, mark, audio, video {
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
......
......@@ -14,6 +14,7 @@ a:active { color: #007BE6; }
/*--------------------------------HEADER-------------------------------*/
#logo {
margin-left: 5%;
display: inline-block;
}
header {
display: block;
......@@ -75,6 +76,29 @@ header form {
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 {
display: block;
......
......@@ -17,6 +17,17 @@
{% if not popup %}
<div id="logo"><a href="{{ url('core:index') }}"><img src="{{ static('core/img/logo.png') }}"
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>
{% if not user.is_authenticated() %}
<a href="{{ url('core:login') }}">{% trans %}Login{% endtrans %}</a>
......
......@@ -3,9 +3,7 @@
{% block title %}
{% trans %}Welcome!{% endtrans %}
{% endblock %}
{% block content %}
<p>{% trans %}Welcome to the new AE's website!{% endtrans %}</p>
<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>
{{ get_sith().index_page|markdown }}
{% endblock %}
......@@ -65,7 +65,10 @@
<hr>
<h4>{% trans %}Communication{% endtrans %}</h4>
<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>
{% endif %}
{% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
......
......@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"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"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
......@@ -85,12 +85,12 @@ msgstr "Compte club"
msgid "%(club_account)s on %(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
msgid "start date"
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"
msgstr "date de fin"
......@@ -123,13 +123,13 @@ msgstr "numéro"
msgid "journal"
msgstr "classeur"
#: accounting/models.py:194 core/models.py:530 core/models.py:876
#: core/models.py:916 counter/models.py:242 counter/models.py:290
#: counter/models.py:415 eboutic/models.py:15 eboutic/models.py:48
#: accounting/models.py:194 core/models.py:530 core/models.py:875
#: core/models.py:915 counter/models.py:242 counter/models.py:290
#: counter/models.py:416 eboutic/models.py:15 eboutic/models.py:48
msgid "date"
msgstr "date"
#: accounting/models.py:195 counter/models.py:416
#: accounting/models.py:195 counter/models.py:417
msgid "comment"
msgstr "commentaire"
......@@ -190,7 +190,7 @@ msgstr "Compte"
msgid "Company"
msgstr "Entreprise"
#: accounting/models.py:207 sith/settings.py:286
#: accounting/models.py:207 sith/settings.py:296
msgid "Other"
msgstr "Autre"
......@@ -678,7 +678,7 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs"
msgid "A club with that unix_name already exists"
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
#: launderette/models.py:124 sas/models.py:131
msgid "user"
......@@ -844,7 +844,7 @@ msgid "Payment method"
msgstr "Méthode de paiement"
#: club/templates/club/club_tools.jinja:4
#: core/templates/core/user_tools.jinja:78
#: core/templates/core/user_tools.jinja:81
msgid "Club tools"
msgstr "Outils club"
......@@ -868,7 +868,7 @@ msgstr "Membres"
msgid "Old members"
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
msgid "Tools"
msgstr "Outils"
......@@ -900,6 +900,34 @@ msgstr "Date de fin"
msgid "Product"
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
msgid "meta group status"
msgstr "status du meta-groupe"
......@@ -1202,7 +1230,7 @@ msgstr "Montrez vos statistiques de compte aux autres"
msgid "file name"
msgstr "nom du fichier"
#: core/models.py:520 core/models.py:721
#: core/models.py:520 core/models.py:720
msgid "parent"
msgstr "parent"
......@@ -1222,11 +1250,11 @@ msgstr "miniature"
msgid "owner"
msgstr "propriétaire"
#: core/models.py:525 core/models.py:727
#: core/models.py:525 core/models.py:726
msgid "edit group"
msgstr "groupe d'édition"
#: core/models.py:526 core/models.py:728
#: core/models.py:526 core/models.py:727
msgid "view group"
msgstr "groupe de vue"
......@@ -1276,64 +1304,64 @@ msgstr "Un fichier de ce nom existe déjà"
msgid "You must provide a file"
msgstr "Vous devez fournir un fichier"
#: core/models.py:670
#: core/models.py:669
msgid "Folder: "
msgstr "Dossier : "
#: core/models.py:672
#: core/models.py:671
msgid "File: "
msgstr "Fichier : "
#: core/models.py:720 core/models.py:724
#: core/models.py:719 core/models.py:723
msgid "page name"
msgstr "nom de la page"
#: core/models.py:725
#: core/models.py:724
msgid "owner group"
msgstr "groupe propriétaire"
#: core/models.py:729
#: core/models.py:728
msgid "lock user"
msgstr "utilisateur bloquant"
#: core/models.py:730
#: core/models.py:729
msgid "lock_timeout"
msgstr "décompte du déblocage"
#: core/models.py:757
#: core/models.py:756
msgid "Duplicate page"
msgstr "Une page de ce nom existe déjà"
#: core/models.py:763
#: core/models.py:762
msgid "Loop in page tree"
msgstr "Boucle dans l'arborescence des pages"
#: core/models.py:873
#: core/models.py:872
msgid "revision"
msgstr "révision"
#: core/models.py:874
#: core/models.py:873
msgid "page title"
msgstr "titre de la page"
#: core/models.py:875
#: core/models.py:874
msgid "page content"
msgstr "contenu de la page"
#: core/models.py:913
#: core/models.py:912
msgid "url"
msgstr "url"
#: core/models.py:914
#: core/models.py:913
msgid "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
msgid "type"
msgstr "type"
#: core/models.py:917
#: core/models.py:916
msgid "viewed"
msgstr "vue"
......@@ -1353,91 +1381,91 @@ msgstr "Bienvenue!"
msgid "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
msgid "Login"
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"
msgstr "S'enregister"
#: core/templates/core/base.jinja:50
#: core/templates/core/base.jinja:61
msgid "View more"
msgstr "Voir plus"
#: core/templates/core/base.jinja:51
#: core/templates/core/base.jinja:62
msgid "Mark all as read"
msgstr "Marquer tout commme lu"
#: core/templates/core/base.jinja:54
#: core/templates/core/base.jinja:65
msgid "Logout"
msgstr "Déconnexion"
#: core/templates/core/base.jinja:56 core/templates/core/base.jinja.py:57
#: core/templates/core/base.jinja:67 core/templates/core/base.jinja.py:68
msgid "Search"
msgstr "Recherche"
#: core/templates/core/base.jinja:79
#: core/templates/core/base.jinja:90
msgid "Main"
msgstr "Accueil"
#: core/templates/core/base.jinja:80
#: core/templates/core/base.jinja:91
msgid "Matmatronch"
msgstr "Matmatronch"
#: core/templates/core/base.jinja:81
#: core/templates/core/base.jinja:92
msgid "Wiki"
msgstr "Wiki"
#: core/templates/core/base.jinja:82 sas/templates/sas/album.jinja:4
#: core/templates/core/base.jinja:93 sas/templates/sas/album.jinja:4
#: sas/templates/sas/main.jinja:4 sas/templates/sas/main.jinja.py:8
#: sas/templates/sas/picture.jinja:26
msgid "SAS"
msgstr "SAS"
#: core/templates/core/base.jinja:83
#: core/templates/core/base.jinja:94
msgid "Forum"
msgstr "Forum"
#: core/templates/core/base.jinja:84
#: core/templates/core/base.jinja:95
msgid "Services"
msgstr "Services"
#: core/templates/core/base.jinja:85 core/templates/core/file.jinja:20
#: core/templates/core/base.jinja:96 core/templates/core/file.jinja:20
#: core/views/files.py:50
msgid "Files"
msgstr "Fichiers"
#: core/templates/core/base.jinja:86
#: core/templates/core/base.jinja:97
msgid "Sponsors"
msgstr "Partenaires"
#: core/templates/core/base.jinja:87
#: core/templates/core/base.jinja:98
msgid "Help"
msgstr "Aide"
#: core/templates/core/base.jinja:120
#: core/templates/core/base.jinja:131
msgid "Contacts"
msgstr "Contacts"
#: core/templates/core/base.jinja:121
#: core/templates/core/base.jinja:132
msgid "Legal notices"
msgstr "Mentions légales"
#: core/templates/core/base.jinja:122
#: core/templates/core/base.jinja:133
msgid "Intellectual property"
msgstr "Propriété intellectuelle"
#: core/templates/core/base.jinja:123
#: core/templates/core/base.jinja:134
msgid "Help & Documentation"
msgstr "Aide & Documentation"
#: core/templates/core/base.jinja:124
#: core/templates/core/base.jinja:135
msgid "R&D"
msgstr "R&D"
#: core/templates/core/base.jinja:126
#: core/templates/core/base.jinja:137
msgid "Site made by good people"
msgstr "Site réalisé par des gens bons"
......@@ -1516,10 +1544,8 @@ msgid "Paste"
msgstr "Coller"
#: core/templates/core/file_detail.jinja:31 sas/templates/sas/album.jinja:32
#, fuzzy
#| msgid "Clear clipboard"
msgid "Clipboard: "
msgstr "Vider le presse-papier"
msgstr "Presse-papier : "
#: core/templates/core/file_detail.jinja:53
msgid "Real name: "
......@@ -1589,10 +1615,6 @@ msgstr "Liste des groupes"
msgid "New group"
msgstr "Nouveau groupe"
#: core/templates/core/index.jinja:7
msgid "Welcome to the new AE's website!"
msgstr "Bienvenue sur le nouveau site de l'AE ! "
#: core/templates/core/login.jinja:10
msgid "Your username and password didn't match. Please try again."
msgstr ""
......@@ -2122,10 +2144,22 @@ msgid "Communication"
msgstr "Communication"
#: core/templates/core/user_tools.jinja:69
msgid "Edit index page"
msgstr "Éditer la page d'accueil"
#: core/templates/core/user_tools.jinja:70
msgid "Edit alert message"
msgstr "Éditer le message d'alerte"
#: core/templates/core/user_tools.jinja:71
msgid "Edit information message"
msgstr "Éditer le message d'informations"
#: core/templates/core/user_tools.jinja:72
msgid "Moderate files"
msgstr "Modérer les fichiers"
#: core/templates/core/user_tools.jinja:72
#: core/templates/core/user_tools.jinja:75
msgid "Moderate pictures"
msgstr "Modérer les photos"
......@@ -2249,7 +2283,7 @@ msgstr "groupe d'achat"
msgid "archived"
msgstr "archivé"
#: counter/models.py:113 counter/models.py:496
#: counter/models.py:113 counter/models.py:497
msgid "product"
msgstr "produit"
......@@ -2274,7 +2308,7 @@ msgstr "Bureau"
#: eboutic/templates/eboutic/eboutic_main.jinja:24
#: eboutic/templates/eboutic/eboutic_makecommand.jinja:8
#: eboutic/templates/eboutic/eboutic_payment_result.jinja:4
#: sith/settings.py:285 sith/settings.py:293
#: sith/settings.py:295 sith/settings.py:303
msgid "Eboutic"
msgstr "Eboutic"
......@@ -2286,7 +2320,7 @@ msgstr "vendeurs"
msgid "token"
msgstr "jeton"
#: counter/models.py:142 counter/models.py:397 counter/models.py:414
#: counter/models.py:142 counter/models.py:398 counter/models.py:415
#: launderette/models.py:14
msgid "counter"
msgstr "comptoir"
......@@ -2307,7 +2341,7 @@ msgstr "rechargement"
msgid "unit price"
msgstr "prix unitaire"
#: counter/models.py:287 counter/models.py:486 eboutic/models.py:104
#: counter/models.py:287 counter/models.py:487 eboutic/models.py:104
msgid "quantity"
msgstr "quantité"
......@@ -2315,8 +2349,8 @@ msgstr "quantité"
msgid "Sith account"
msgstr "Compte utilisateur"
#: counter/models.py:292 sith/settings.py:278 sith/settings.py:283
#: sith/settings.py:305
#: counter/models.py:292 sith/settings.py:288 sith/settings.py:293
#: sith/settings.py:315
msgid "Credit card"
msgstr "Carte bancaire"
......@@ -2342,51 +2376,51 @@ msgstr ""
"Vous avez acheté un Eticket pour l'événement %(event)s.\n"
"Vous pouvez le télécharger sur cette page: %(url)s"
#: counter/models.py:400
#: counter/models.py:401
msgid "last activity date"
msgstr "dernière activité"
#: counter/models.py:403
#: counter/models.py:404
msgid "permanency"
msgstr "permanence"
#: counter/models.py:417
#: counter/models.py:418
msgid "emptied"
msgstr "coffre vidée"
#: counter/models.py:420
#: counter/models.py:421
msgid "cash register summary"
msgstr "relevé de caisse"
#: counter/models.py:484
#: counter/models.py:485
msgid "cash summary"
msgstr "relevé"
#: counter/models.py:485
#: counter/models.py:486
msgid "value"
msgstr "valeur"
#: counter/models.py:487
#: counter/models.py:488
msgid "check"
msgstr "chèque"
#: counter/models.py:490
#: counter/models.py:491
msgid "cash register summary item"
msgstr "élément de relevé de caisse"
#: counter/models.py:497
#: counter/models.py:498
msgid "banner"
msgstr "bannière"
#: counter/models.py:498
#: counter/models.py:499
msgid "event date"
msgstr "date de l'événement"