cleaning up, improved scripts and menus

This commit is contained in:
Arthur Gerbaud
2016-08-13 20:59:48 +02:00
parent 12f23b8acb
commit 128314bcb3
25 changed files with 274 additions and 209 deletions
+13 -24
View File
@@ -82,28 +82,22 @@ class WebsiteTemplateMixin(TemplateResponseMixin):
self.app_name = self.__class__.__module__.split(".")[0]
return apps.get_app_config(self.app_name)
@property
def active_app(self):
if not hasattr(self, '_active_app'):
self._active_app = self.get_active_app()
return self._active_app
def get_menu(self):
""" Renvoie la liste des templates utilisés comme menu pour l'application
active
"""
return self.app_menu
def get_prochaine_maraude_for_user(self):
""" Retourne le prochain objet Maraude auquel
l'utilisateur participe, ou None """
maraudeur_cls = apps.get_model('utilisateurs', model_name="Maraudeur")
maraude_cls = apps.get_model('maraudes', model_name="Maraude")
try: #TODO: Clean up this ugly thing
self.maraudeur = maraudeur_cls.objects.get(username=self.request.user.username)
except:
self.maraudeur = None
if self.maraudeur:
return maraude_cls.objects.get_next_of(self.maraudeur)
return None
def get_prochaine_maraude(self):
return apps.get_model('maraudes', model_name="Maraude").objects.next
def insert_menu(self, template_name):
""" Insert menu at beginning of self.app_menu """
if not template_name in self.app_menu:
self.app_menu.insert(0, template_name)
def _update_context_with_rendered_blocks(self, context):
""" Render text for existing PageInfo attributes.
@@ -116,18 +110,13 @@ class WebsiteTemplateMixin(TemplateResponseMixin):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
self._update_context_with_rendered_blocks(context)
context['stylesheets'] = self.Configuration.stylesheets
context['apps'] = self.Configuration.apps
context['active_app'] = self.get_active_app()
context['active_app'] = self.active_app
#Webpage
context['content_template'] = self.get_content_template()
context['app_menu'] = self.get_menu()
context['prochaine_maraude_abs'] = self.get_prochaine_maraude()
context['prochaine_maraude'] = self.get_prochaine_maraude_for_user()
self._update_context_with_rendered_blocks(context)
return context
class WebsiteAjaxTemplateMixin(WebsiteTemplateMixin):
+15 -5
View File
@@ -1,17 +1,27 @@
#menu {
border: none;
border-right: 4px solid #f47f02;
border-right: 4px solid #980300;
}
.dropdown-toggle{
border-right: 4px solid #980300 !important;
}
.dropdown-menu {
border-bottom: none !important;
}
.navbar-fixed-side .navbar-nav>li>a {
border-bottom: none;
color: #fff;
}
.app-menu {
background-color: #121212;
border: none;
}
#sidebar {
padding-top:10px;
border-bottom: 4px solid #f47f02;
border-top: 4px solid #f47f02;
@media (max-width:768px){
#menu { border: none; }
}
+4 -4
View File
@@ -164,12 +164,12 @@
"@navbar-default-toggle-border-color": "#ddd",
"@navbar-inverse-color": "lighten(@gray-light, 15%)",
"@navbar-inverse-bg": "#222",
"@navbar-inverse-border": "#f47f02",
"@navbar-inverse-border": "#333",
"@navbar-inverse-link-color": "lighten(@gray-light, 15%)",
"@navbar-inverse-link-hover-color": "#fff",
"@navbar-inverse-link-hover-bg": "transparent",
"@navbar-inverse-link-active-color": "@navbar-inverse-link-hover-color",
"@navbar-inverse-link-active-bg": "#f47f02",
"@navbar-inverse-link-active-bg": "@brand-primary",
"@navbar-inverse-link-disabled-color": "#444",
"@navbar-inverse-link-disabled-bg": "transparent",
"@navbar-inverse-brand-color": "@navbar-inverse-link-color",
@@ -379,7 +379,7 @@
"@page-header-border-color": "@hr-border",
"@dl-horizontal-offset": "@component-offset-horizontal",
"@dl-horizontal-breakpoint": "@grid-float-breakpoint",
"@hr-border": "@gray-light"
"@hr-border": "lighten(@gray-base, 83.5%)"
},
"css": [
"print.less",
@@ -431,5 +431,5 @@
"scrollspy.js",
"transition.js"
],
"customizerUrl": "http://getbootstrap.com/customize/?id=3e0cac7da17e620f3ce026228727422b"
"customizerUrl": "https://getbootstrap.com/customize/?id=4e370b35f1630f31fde8e0de59c1c6f5"
}
+7 -7
View File
@@ -5,8 +5,8 @@
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3e0cac7da17e620f3ce026228727422b)
* Config saved to config.json and https://gist.github.com/3e0cac7da17e620f3ce026228727422b
* Generated using the Bootstrap Customizer (https://getbootstrap.com/customize/?id=4e370b35f1630f31fde8e0de59c1c6f5)
* Config saved to config.json and https://gist.github.com/4e370b35f1630f31fde8e0de59c1c6f5
*/
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
@@ -384,12 +384,12 @@ fieldset[disabled] .btn-danger.active {
}
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .active > a {
background-image: -webkit-linear-gradient(top, #f47f02 0%, #fd8506 100%);
background-image: -o-linear-gradient(top, #f47f02 0%, #fd8506 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f47f02), to(#fd8506));
background-image: linear-gradient(to bottom, #f47f02 0%, #fd8506 100%);
background-image: -webkit-linear-gradient(top, #980300 0%, #a50300 100%);
background-image: -o-linear-gradient(top, #980300 0%, #a50300 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#980300), to(#a50300));
background-image: linear-gradient(to bottom, #980300 0%, #a50300 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff47f02', endColorstr='#fffd8506', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff980300', endColorstr='#ffa50300', GradientType=0);
-webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, 0.25);
box-shadow: inset 0 3px 9px rgba(0, 0, 0, 0.25);
}
File diff suppressed because one or more lines are too long
+10 -10
View File
@@ -5,8 +5,8 @@
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3e0cac7da17e620f3ce026228727422b)
* Config saved to config.json and https://gist.github.com/3e0cac7da17e620f3ce026228727422b
* Generated using the Bootstrap Customizer (https://getbootstrap.com/customize/?id=4e370b35f1630f31fde8e0de59c1c6f5)
* Config saved to config.json and https://gist.github.com/4e370b35f1630f31fde8e0de59c1c6f5
*/
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
@@ -1153,7 +1153,7 @@ hr {
margin-top: 20px;
margin-bottom: 20px;
border: 0;
border-top: 1px solid #777777;
border-top: 1px solid #d5d5d5;
}
.sr-only {
position: absolute;
@@ -1416,7 +1416,7 @@ a.bg-danger:focus {
.page-header {
padding-bottom: 9px;
margin: 40px 0 20px;
border-bottom: 1px solid #777777;
border-bottom: 1px solid #d5d5d5;
}
ul,
ol {
@@ -4596,7 +4596,7 @@ fieldset[disabled] .navbar-default .btn-link:focus {
}
.navbar-inverse {
background-color: #222222;
border-color: #f47f02;
border-color: #333333;
}
.navbar-inverse .navbar-brand {
color: #9d9d9d;
@@ -4621,7 +4621,7 @@ fieldset[disabled] .navbar-default .btn-link:focus {
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
color: #ffffff;
background-color: #f47f02;
background-color: #980300;
}
.navbar-inverse .navbar-nav > .disabled > a,
.navbar-inverse .navbar-nav > .disabled > a:hover,
@@ -4646,15 +4646,15 @@ fieldset[disabled] .navbar-default .btn-link:focus {
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .open > a:hover,
.navbar-inverse .navbar-nav > .open > a:focus {
background-color: #f47f02;
background-color: #980300;
color: #ffffff;
}
@media (max-width: 767px) {
.navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {
border-color: #f47f02;
border-color: #333333;
}
.navbar-inverse .navbar-nav .open .dropdown-menu .divider {
background-color: #f47f02;
background-color: #333333;
}
.navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
color: #9d9d9d;
@@ -4668,7 +4668,7 @@ fieldset[disabled] .navbar-default .btn-link:focus {
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
.navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
color: #ffffff;
background-color: #f47f02;
background-color: #980300;
}
.navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,
.navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -5,8 +5,8 @@
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=3e0cac7da17e620f3ce026228727422b)
* Config saved to config.json and https://gist.github.com/3e0cac7da17e620f3ce026228727422b
* Generated using the Bootstrap Customizer (https://getbootstrap.com/customize/?id=4e370b35f1630f31fde8e0de59c1c6f5)
* Config saved to config.json and https://gist.github.com/4e370b35f1630f31fde8e0de59c1c6f5
*/
if (typeof jQuery === 'undefined') {
throw new Error('Bootstrap\'s JavaScript requires jQuery')
File diff suppressed because one or more lines are too long
View File
+41
View File
@@ -0,0 +1,41 @@
$(function() {
var input = $('#id_heure_debut')
var min_value = input.attr('value').split(":")
var is_morning = (min_value[0] <= 12)
$.fn.editHeureValue = function(mod) {
var value = input.attr('value').split(":");
var new_hour = parseInt(value[0]);
var new_minutes = parseInt(value[1]) + mod;
if (new_minutes >= 60) {
new_hour += 1;
new_minutes -= 60;
} else if (new_minutes < 0) {
new_hour -= 1;
new_minutes += 60;
};
if (new_hour >= 24) {
new_hour -= 24;
} else if (new_hour < 0) {
new_hour += 24
};
value[0] = new_hour;
value[1] = new_minutes;
var test_value = value[0] * 10000 + value[1] * 100 + parseInt(value[2]);
var test_min_value = min_value[0] * 10000 + min_value[1] *100 + parseInt(min_value[2]);
console.log('test:', test_value, 'min:', test_min_value)
if (test_value >= test_min_value || (!is_morning && test_value < 120000)) {
input.attr('value', value.join(":"));
console.log('updated!')
};
};
$('#minus-5').click(function() {
$.fn.editHeureValue(-5)
console.log('minus 5')
});
$('#plus-5').click(function() {
$.fn.editHeureValue(5)
console.log('plus 5')
});
});
+2 -2
View File
@@ -3,9 +3,9 @@
<html lang="fr">
<head>
<title>{% block title %}La maraude{% endblock %}</title>
{# Load Bootstrap CSS and JavaScript #}{% bootstrap_css %}{% bootstrap_javascript %}
{# Side Navbar from http://www.samrayner.com/bootstrap-side-navbar/inverse.html #}<link href="/static/bootstrap/navbar-fixed-side.css" rel="stylesheet" />
{% if stylesheets %}{% for stylesheet in stylesheets %}<link rel="stylesheet" type="text/css" href="{% static stylesheet %}" />{% endfor %}{% endif %}
{# Load CSS and JavaScript #}{% bootstrap_css %}{% bootstrap_javascript %}
<link href="/static/bootstrap/navbar-fixed-side.css" rel="stylesheet" />
</head>
<body>
<div class="container-fluid">
+1 -1
View File
@@ -13,7 +13,7 @@
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">{% for app in apps %}
<li {% if app == active_app %} class="active" {%endif%}>
<a href="/{{app.label}}/"><strong style="color:#fff;">{{ app.name|title }}</strong></a>
<a href="/{{app.label}}/"><strong>{{ app.name|title }}</strong></a>
</li>
{% if app == active_app %}{% for t in app_menu %}{% include t %}{% endfor %}{% endif %}
{%endfor%}
+1 -1
View File
@@ -10,7 +10,7 @@ class Index(WebsiteTemplateMixin, views.generic.TemplateView):
class PageInfo:
title = "La maraude ALSA"
header = "La Maraude ALSA"
header_small = "informations"
header_small = "accueil"
def get(self, request, *args, **kwargs):
if not request.user.is_authenticated():