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,13 +4,13 @@ html, body, div, span, applet, object, iframe, ...@@ -4,13 +4,13 @@ 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,
table, caption, tbody, tfoot, thead, tr, th, td, table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup, figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary, menu, nav, output, ruby, section, summary,
time, mark, audio, video { time, mark, audio, video {
margin: 0; margin: 0;
...@@ -21,7 +21,7 @@ time, mark, audio, video { ...@@ -21,7 +21,7 @@ time, mark, audio, video {
vertical-align: baseline; vertical-align: baseline;
} }
/* HTML5 display-role reset for older browsers */ /* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section { footer, header, hgroup, menu, nav, section {
display: block; display: block;
} }
......
...@@ -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) %}
......
This diff is collapsed.
...@@ -57,6 +57,7 @@ INSTALLED_APPS = ( ...@@ -57,6 +57,7 @@ INSTALLED_APPS = (
'api', 'api',
'rootplace', 'rootplace',
'sas', 'sas',
'com',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
...@@ -117,6 +118,7 @@ TEMPLATES = [ ...@@ -117,6 +118,7 @@ TEMPLATES = [
"Counter": "counter.models.Counter", "Counter": "counter.models.Counter",
"ProductType": "counter.models.ProductType", "ProductType": "counter.models.ProductType",
"timezone": "django.utils.timezone", "timezone": "django.utils.timezone",
"get_sith": "com.views.sith",
}, },
"bytecode_cache": { "bytecode_cache": {
"name": "default", "name": "default",
......
...@@ -31,6 +31,7 @@ urlpatterns = [ ...@@ -31,6 +31,7 @@ urlpatterns = [
url(r'^', include('core.urls', namespace="core", app_name="core")), url(r'^', include('core.urls', namespace="core", app_name="core")),
url(r'^rootplace/', include('rootplace.urls', namespace="rootplace", app_name="rootplace")), url(r'^rootplace/', include('rootplace.urls', namespace="rootplace", app_name="rootplace")),
url(r'^subscription/', include('subscription.urls', namespace="subscription", app_name="subscription")), url(r'^subscription/', include('subscription.urls', namespace="subscription", app_name="subscription")),
url(r'^com/', include('com.urls', namespace="com", app_name="com")),
url(r'^club/', include('club.urls', namespace="club", app_name="club")), url(r'^club/', include('club.urls', namespace="club", app_name="club")),
url(r'^counter/', include('counter.urls', namespace="counter", app_name="counter")), url(r'^counter/', include('counter.urls', namespace="counter", app_name="counter")),
url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")), url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment