diff --git a/kfet/forms.py b/kfet/forms.py index 09c3a4d0..95e97d56 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -8,7 +8,7 @@ from django.core.exceptions import ValidationError from django.core.validators import MinLengthValidator from django.contrib.auth.models import User, Group, Permission from django.contrib.contenttypes.models import ContentType -from django.forms import modelformset_factory +from django.forms import modelformset_factory, widgets from django.utils import timezone from djconfig.forms import ConfigForm @@ -151,10 +151,24 @@ class UserGroupForm(forms.ModelForm): fields = ['groups'] +class KFetPermissionsField(forms.ModelMultipleChoiceField): + + def __init__(self, *args, **kwargs): + queryset = Permission.objects.filter( + content_type__in=ContentType.objects.filter(app_label="kfet"), + ) + super().__init__( + queryset=queryset, + widget=widgets.CheckboxSelectMultiple, + *args, **kwargs + ) + + def label_from_instance(self, obj): + return obj.name + + class GroupForm(forms.ModelForm): - permissions = forms.ModelMultipleChoiceField( - queryset= Permission.objects.filter(content_type__in= - ContentType.objects.filter(app_label='kfet'))) + permissions = KFetPermissionsField() def clean_name(self): name = self.cleaned_data['name'] @@ -525,11 +539,7 @@ class OrderArticleForm(forms.Form): self.category = kwargs['initial']['category'] self.category_name = kwargs['initial']['category__name'] self.box_capacity = kwargs['initial']['box_capacity'] - self.v_s1 = kwargs['initial']['v_s1'] - self.v_s2 = kwargs['initial']['v_s2'] - self.v_s3 = kwargs['initial']['v_s3'] - self.v_s4 = kwargs['initial']['v_s4'] - self.v_s5 = kwargs['initial']['v_s5'] + self.v_all = kwargs['initial']['v_all'] self.v_moy = kwargs['initial']['v_moy'] self.v_et = kwargs['initial']['v_et'] self.v_prev = kwargs['initial']['v_prev'] diff --git a/kfet/signals.py b/kfet/signals.py index 3dd4d677..e81f264a 100644 --- a/kfet/signals.py +++ b/kfet/signals.py @@ -1,16 +1,18 @@ # -*- coding: utf-8 -*- -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * - from django.contrib import messages from django.contrib.auth.signals import user_logged_in from django.core.urlresolvers import reverse from django.dispatch import receiver + @receiver(user_logged_in) def messages_on_login(sender, request, user, **kwargs): - if (not user.username == 'kfet_genericteam' - and user.has_perm('kfet.is_team')): - messages.info(request, 'Connexion en utilisateur partagé ?' % reverse('kfet.login.genericteam'), extra_tags='safe') + if (not user.username == 'kfet_genericteam' and + user.has_perm('kfet.is_team') and + 'k-fet' in request.GET.get('next', '')): + messages.info( + request, + ('Connexion en utilisateur partagé ?' + .format(reverse('kfet.login.genericteam'))), + extra_tags='safe') diff --git a/kfet/static/kfet/css/history.css b/kfet/static/kfet/css/history.css index 976f5782..dff7a455 100644 --- a/kfet/static/kfet/css/history.css +++ b/kfet/static/kfet/css/history.css @@ -9,17 +9,20 @@ #history .day { height:40px; line-height:40px; - background-color:#c8102e; + background-color:rgba(200,16,46,0.9); color:#fff; padding-left:20px; font-size:16px; font-weight:bold; + position:sticky; + top:50px; + z-index:10; } #history .opegroup { height:30px; line-height:30px; - background-color:rgba(200,16,46,0.85); + background-color:rgba(200,16,46,0.75); color:#fff; font-weight:bold; padding-left:20px; diff --git a/kfet/static/kfet/css/index.css b/kfet/static/kfet/css/index.css index 0244a57b..15b425e2 100644 --- a/kfet/static/kfet/css/index.css +++ b/kfet/static/kfet/css/index.css @@ -33,10 +33,8 @@ textarea { .table { margin-bottom:0; border-bottom:1px solid #ddd; -} - -.table { width:100%; + background-color: #FFF; } .table td { @@ -70,6 +68,16 @@ textarea { padding:8px 30px; } +.table-responsive { + border: 0; + margin-bottom: 0; +} + +.btn { + transition: background-color, color; + transition-duration: 0.15s; +} + .btn, .btn-lg, .btn-group-lg>.btn { border-radius:0; } @@ -81,19 +89,30 @@ textarea { border:0; } -.btn-primary:hover, .btn-primary.focus, .btn-primary:focus { - background-color:#000; +.btn-primary:hover, +.btn-primary.focus, .btn-primary:focus, +.btn-primary.active.focus, .btn-primary.active:focus, .btn-primary.active:hover, +.btn-primary:active.focus, .btn-primary:active:focus, .btn-primary:active:hover, +.nav-pills>li.active>a, .nav-pills>li.active>a:focus, .nav-pills>li.active>a:hover { + outline: 0; + background-color:rgba(200,16,46,1); color:#FFF; } -.buttons .nav-pills > li > a { - border-radius:0; - border:1px solid rgba(200,16,46,0.9); +.btn-primary[disabled]:hover, +.btn-primary[disabled]:focus { + background-color: #000; + color: #666; } -.buttons .nav-pills > li.active > a { - background-color:rgba(200,16,46,0.9); - background-clip:padding-box; +.nav-pills>li>a { + border-radius:0; +} + +.nav-pills>li>a:focus, .nav-pills>li>a:hover { + outline: 0; + background-color:rgba(200,16,46,1); + color:#FFF; } .row-page-header { @@ -114,26 +133,17 @@ textarea { padding: 0 !important; } -.panel-md-margin{ - background-color: white; - overflow:hidden; - padding-left: 15px; - padding-right: 15px; - padding-bottom: 15px; - padding-top: 1px; -} - -@media (min-width: 992px) { - .panel-md-margin{ - margin:8px; - background-color: white; - } -} - .col-content-left, .col-content-right { padding:0; } +@media (min-width: 768px) { + .col-content-left { + position: sticky; + top:50px; + } +} + .content-left-top { background:#fff; padding:10px 30px; @@ -147,6 +157,14 @@ textarea { display:block; } +.content-left .buttons ul.nav-pills { + margin-bottom:5px; +} + +.content-left .buttons ul.nav-pills li { + margin:0 0 -5px; +} + .content-left-top.frozen-account { background:#000FBA; color:#fff; @@ -179,25 +197,22 @@ textarea { text-align:center; } -.content-right { - margin:0 15px; +@media (min-width: 768px) { + .content-right { + margin: 15px; + } } .content-right-block { - padding-bottom:5px; position:relative; } -.content-right-block:last-child { - padding-bottom:15px; +.content-right-block > *:not(.buttons-title) { + background: #fff; } -.content-right-block > div:not(.buttons-title) { - background:#fff; -} - -.content-right-block-transparent > div:not(.buttons-title) { - background-color: transparent; +.content-right-block > h2 { + background: transparent !important; } .content-right-block .buttons-title { @@ -219,9 +234,8 @@ textarea { .content-right-block h3 { border-bottom: 1px solid #c8102e; - margin: 20px 15px 15px; - padding-bottom: 10px; - padding-left: 20px; + margin: 0px 15px 15px; + padding: 20px 20px 10px; font-size:25px; } @@ -229,20 +243,34 @@ textarea { * Pages tableaux seuls */ -.content-center > div { - background:#fff; +.content-center > *:not(.content-right-block) { + background: #fff; +} + +@media (min-width: 992px) { + .content-center { + margin: 15px 0; + } } .content-center tbody tr:not(.section) td { - padding:0px 5px !important; + padding:0px 5px; } -.content-center .table .form-control { +.table .form-control { padding: 1px 12px ; height:28px; margin:3px 0px; } - .content-center .auth-form { + +.table-condensed input.form-control { + margin: 0 !important; + border-top: 0; + border-bottom: 0; + border-radius: 0; +} + +.content-center .auth-form { margin:15px; } @@ -250,15 +278,12 @@ textarea { * Pages formulaires seuls */ -.form-only .content-form { - margin:15px; - - background:#fff; - - padding:15px; +.content-form { + background-color: #fff; + padding: 15px; } -.form-only .account_create #id_trigramme { +.account_create #id_trigramme { display:block; width:200px; height:80px; @@ -324,6 +349,10 @@ textarea { * Messages */ +.messages { + margin: 0; +} + .messages .alert { padding:10px 15px; margin:0; @@ -561,21 +590,67 @@ thead .tooltip { } } -.help-block { - padding-top: 15px; -} - /* Inventaires */ +#inventoryform input[type=number] { + text-align: center; +} + .inventory_modified { background:rgba(236,100,0,0.15); } .stock_diff { padding-left: 5px; - color:#C8102E; + color:#C8102E; } .inventory_update { - display:none; + display: none; + width: 50px; + margin: 0 auto; +} + +/* Multiple select customizations */ + +.ms-choice { + height: 34px !important; + line-height: 34px !important; + border: 1px solid #ccc !important; + box-shadow: inset 0 1px 1px rgba(0,0,0,.075) !important; +} + +.ms-choice > div { + top: 4px !important; +} + +/* Checkbox select multiple */ + +.checkbox-select-multiple label { + font-weight: normal; + margin-bottom: 0; +} + +/* Statement creation */ + +.statement-create-summary table { + margin: 0 auto; +} + +.statement-create-summary tr td { + text-align: right; +} + +.statement-create-summary tr td:first-child { + padding-right: 15px; + font-weight: bold; +} + +.statement-create-summary tr td:last-child { + width: 80px; +} + +#detail_taken table td, +#detail_balance table td { + padding: 0; } diff --git a/kfet/static/kfet/css/kpsul.css b/kfet/static/kfet/css/kpsul.css index ba88e433..4b60aa7b 100644 --- a/kfet/static/kfet/css/kpsul.css +++ b/kfet/static/kfet/css/kpsul.css @@ -143,7 +143,7 @@ input[type=number]::-webkit-outer-spin-button { height:50px; padding:0 15px; - background:#c8102e; + background:rgba(200,16,46,0.9); color:#fff; font-weight:bold; @@ -232,16 +232,21 @@ input[type=number]::-webkit-outer-spin-button { float:left; - background:#c8102e; + background: rgba(200,16,46,0.9); color:#FFF; font-size:18px; font-weight:bold; + + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } -#special_operations button:focus, #special_operations button:hover { +#special_operations button:focus, +#special_operations button:hover { outline:none; - background:#000; + background: rgba(200,16,46,1); color:#fff; } @@ -256,15 +261,14 @@ input[type=number]::-webkit-outer-spin-button { height:100%; float:left; border:0; - border-right:1px solid #c8102e; - border-bottom:1px solid #c8102e; border-radius:0; + border-bottom: 1px solid rgba(200,16,46,0.9); font-size:16px; font-weight:bold; } -#article_selection input+input #article_selection input+span { - border-right:0; +#article_selection input:first-child { + border-right: 1px dashed rgba(200,16,46,0.9); } #article_autocomplete { @@ -319,7 +323,7 @@ input[type=number]::-webkit-outer-spin-button { #articles_data table tr.category { height:35px; - background-color:#c8102e; + background-color:rgba(200,16,46,0.9); font-size:16px; color:#FFF; font-weight:bold; @@ -423,3 +427,7 @@ input[type=number]::-webkit-outer-spin-button { .kpsul_middle_right_col { overflow:auto; } + +.kpsul_middle_right_col #history .day { + top: 0; +} diff --git a/kfet/static/kfet/css/nav.css b/kfet/static/kfet/css/nav.css index 5ffc7b24..a4dabed2 100644 --- a/kfet/static/kfet/css/nav.css +++ b/kfet/static/kfet/css/nav.css @@ -1,67 +1,88 @@ -nav { - background:#000; - color:#DDD; - font-family:Oswald; +.navbar { + background: #000; + color: #DDD; + font-family: Oswald; + border: 0; } -.navbar-nav > li > .dropdown-menu { - border:0; - border-radius:0; +.navbar .navbar-brand { + padding: 3px 25px; } -.navbar-fixed-top { - border:0; +.navbar .navbar-brand img { + height: 44px; } -nav .navbar-brand { - padding:3px 25px; -} - -nav .navbar-brand img { - height:44px; -} - -nav .navbar-toggle .icon-bar { - background-color:#FFF; -} - -nav a { - color:#DDD; +.navbar .navbar-toggle .icon-bar { + background-color: #FFF; } .navbar-nav { - font-weight:bold; - font-size:14px; - text-transform:uppercase; + font-weight: bold; + font-size: 14px; + text-transform: uppercase; + margin: 0 -15px; } -.nav>li>a:focus, .nav>li>a:hover { - background-color:#C8102E; - color:#FFF; -} - -.nav .open>a, .nav .open>a:focus, .nav .open>a:hover { - background-color:#C8102E; -} - -.dropdown-menu { - padding:0; -} - -.dropdown-menu>li>a { - padding:8px 20px; -} - -.dropdown-menu .divider { - margin:0; -} - -@media (max-width: 767px) { - .navbar-nav .open .dropdown-menu { - background-color:#FFF; - } - +@media (min-width: 768px) { .navbar-nav { - margin:0 -15px; + margin: 0px; + } + .navbar-right { + margin-right: -15px; + } +} + +.navbar-nav a { + transition: background-color, box-shadow, color; + transition-duration: 0.15s; +} + +.navbar-nav > li > a { + color: #FFF; +} + +.navbar-nav > li:hover > a, +.navbar-nav > li > a:focus, +.nav .open > a:hover, +.nav .open > a:focus { + background-color: #C8102E; + color: #FFF; + box-shadow: inset 0 5px 5px -5px #000; +} + +.navbar-nav .dropdown .dropdown-menu { + padding: 0; + border: 0; + border-radius: 0; + background-color: #FFF; +} + +.navbar-nav .dropdown .dropdown-menu > li > a { + padding: 8px 20px; + color: #000; +} + +.navbar-nav .dropdown .dropdown-menu > li > a:hover, +.navbar-nav .dropdown .dropdown-meny > li > a:focus { + color: #c8102e; + background-color: transparent; +} + +.navbar-nav .dropdown .dropdown-menu .divider { + margin: 0; +} + +@media (min-width: 768px) { + .navbar-nav .dropdown .dropdown-menu { + display: block; + visibility: hidden; + opacity: 0; + transition: opacity 0.15s; + } + + .nav .dropdown:hover .dropdown-menu { + visibility: visible; + opacity: 1; } } diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index cc369e32..72ae675a 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -1,14 +1,4 @@ $(document).ready(function() { - $(window).scroll(function() { - if ($(window).width() >= 768 && $(this).scrollTop() > 72.6) { - $('.col-content-left').css({'position':'fixed', 'top':'50px'}); - $('.col-content-right').addClass('col-sm-offset-4 col-md-offset-3'); - } else { - $('.col-content-left').css({'position':'relative', 'top':'0'}); - $('.col-content-right').removeClass('col-sm-offset-4 col-md-offset-3'); - } - }); - if (typeof Cookies !== 'undefined') { // Retrieving csrf token csrftoken = Cookies.get('csrftoken'); diff --git a/kfet/statistic.py b/kfet/statistic.py index 8ffb7db5..3f32807e 100644 --- a/kfet/statistic.py +++ b/kfet/statistic.py @@ -86,7 +86,10 @@ class Scale(object): def get_labels(self, label_fmt=None): if label_fmt is None: label_fmt = self.label_fmt - return [begin.strftime(label_fmt) for begin, end in self] + return [ + begin.strftime(label_fmt.format(i=i, rev_i=len(self)-i)) + for i, (begin, end) in enumerate(self) + ] def chunkify_qs(self, qs, field=None): if field is None: diff --git a/kfet/templates/kfet/account.html b/kfet/templates/kfet/account.html index 76445e73..c8d9b4f9 100644 --- a/kfet/templates/kfet/account.html +++ b/kfet/templates/kfet/account.html @@ -1,67 +1,61 @@ -{% extends "kfet/base.html" %} +{% extends "kfet/base_col_2.html" %} {% block title %}Liste des comptes{% endblock %} -{% block content-header-title %}Comptes{% endblock %} +{% block header-title %}Comptes{% endblock %} -{% block content %} +{% block fixed-content %} -
- | Trigramme | -Nom | -Balance | -COF | -Dpt | -Promo | -
- - - - | -{{ account.trigramme }} | -{{ account.name }} | -{{ account.balance }}€ | -{{ account.is_cof }} | -{{ account.departement }} | -{{ account.promo|default_if_none:'' }} | -
+ | Trigramme | +Nom | +Balance | +COF | +Dpt | +Promo | +
+ + + + | +{{ account.trigramme }} | +{{ account.name }} | +{{ account.balance }}€ | +{{ account.is_cof|yesno:"Oui,Non" }} | +{{ account.departement }} | +{{ account.promo|default_if_none:'' }} | +
Les mots contenant des caractères non alphanumériques seront ignorés
+ +