Commit 0fdc8172a2bfcf798e61762a7be15bcb1c0f3300

Authored by Felipe Bormann
2 parents 7bb19368 abba39a2

Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring

amadeus/context_processors.py
@@ -11,7 +11,11 @@ def theme(request): @@ -11,7 +11,11 @@ def theme(request):
11 theme = Themes.objects.get(id = 1) 11 theme = Themes.objects.get(id = 1)
12 12
13 context['theme'] = theme 13 context['theme'] = theme
14 - 14 + if ("contrast_check" in request.COOKIES.keys()):
  15 + context ['contrast_cookie'] = True
  16 + else:
  17 + context ['contrast_cookie'] = False
  18 +
15 return context 19 return context
16 20
17 def notifies(request): 21 def notifies(request):
@@ -48,4 +52,4 @@ def chat_notifies(request): @@ -48,4 +52,4 @@ def chat_notifies(request):
48 52
49 context['chat_notifications_count'] = notifications 53 context['chat_notifications_count'] = notifications
50 54
51 - return context  
52 \ No newline at end of file 55 \ No newline at end of file
  56 + return context
amadeus/templates/base.html
@@ -63,10 +63,15 @@ @@ -63,10 +63,15 @@
63 <!-- Summernote --> 63 <!-- Summernote -->
64 <script src="{% static 'summernote/summernote.js' %}" type="text/javascript"></script> 64 <script src="{% static 'summernote/summernote.js' %}" type="text/javascript"></script>
65 <link href="{% static 'summernote/summernote.css' %}" type="text/css" rel="stylesheet" /> 65 <link href="{% static 'summernote/summernote.css' %}" type="text/css" rel="stylesheet" />
  66 + {% if contrast_cookie %}
  67 + <link rel="stylesheet" type="text/css" href="{% static 'css/themes/contrast.css' %}">
  68 + {% else %}
  69 + {% with 'css/themes/'|add:theme.css_style|add:'.css' as theme_selected %}
  70 + <link rel="stylesheet" type="text/css" href="{% static theme_selected %}">
  71 + {% endwith %}
  72 + {% endif %}
  73 +
66 74
67 - {% with 'css/themes/'|add:theme.css_style|add:'.css' as theme_selected %}  
68 - <link rel="stylesheet" type="text/css" href="{% static theme_selected %}">  
69 - {% endwith %}  
70 75
71 76
72 </head> 77 </head>
themes/urls.py
@@ -5,5 +5,4 @@ urlpatterns = [ @@ -5,5 +5,4 @@ urlpatterns = [
5 url(r'^$', views.IndexView.as_view(), name = 'manage'), 5 url(r'^$', views.IndexView.as_view(), name = 'manage'),
6 url(r'^basic_elements$', views.BasicElementsSettings.as_view(), name = 'basic'), 6 url(r'^basic_elements$', views.BasicElementsSettings.as_view(), name = 'basic'),
7 url(r'^css_selector$', views.CSSStyleSettings.as_view(), name = 'css'), 7 url(r'^css_selector$', views.CSSStyleSettings.as_view(), name = 'css'),
8 - url(r'^contrast$',views.Contrast, name = 'contrast'),  
9 ] 8 ]
themes/views.py
@@ -3,7 +3,7 @@ from django.shortcuts import render @@ -3,7 +3,7 @@ from django.shortcuts import render
3 from django.contrib import messages 3 from django.contrib import messages
4 from django.core.urlresolvers import reverse, reverse_lazy 4 from django.core.urlresolvers import reverse, reverse_lazy
5 from django.utils.translation import ugettext_lazy as _ 5 from django.utils.translation import ugettext_lazy as _
6 -from django.http import HttpResponse, JsonResponse, HttpResponseRedirect 6 +from django.http import HttpResponse, JsonResponse, HttpResponseRedirect,HttpRequest
7 from django.shortcuts import redirect 7 from django.shortcuts import redirect
8 8
9 from braces import views as braces_mixins 9 from braces import views as braces_mixins
@@ -79,16 +79,3 @@ class CSSStyleSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffuser @@ -79,16 +79,3 @@ class CSSStyleSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffuser
79 context['settings_menu_active'] = "settings_menu_active" 79 context['settings_menu_active'] = "settings_menu_active"
80 80
81 return context 81 return context
82 -  
83 -def Contrast(request):  
84 - theme = Themes.objects.get(id = 1)  
85 -  
86 - if theme.css_style == 'contrast':  
87 - theme.css_style = 'green'  
88 - else:  
89 - theme.css_style = 'contrast'  
90 - theme.save()  
91 -  
92 - caminho = request.META.get('HTTP_REFERER')  
93 -  
94 - return HttpResponseRedirect(caminho)  
users/templates/users/login.html
@@ -87,7 +87,7 @@ @@ -87,7 +87,7 @@
87 <span >[{{LANGUAGE_CODE}}] </span> 87 <span >[{{LANGUAGE_CODE}}] </span>
88 88
89 </a> 89 </a>
90 - <a href="{% url 'themes:contrast'%}" style="margin-left:10px;"><i class="glyphicon glyphicon-adjust"></i></a> 90 + <a href="" id = "contrast_button" style="margin-left:10px;"><i class="glyphicon glyphicon-adjust"></i></a>
91 <ul class="dropdown-menu"> 91 <ul class="dropdown-menu">
92 92
93 93
@@ -146,7 +146,19 @@ @@ -146,7 +146,19 @@
146 </div> 146 </div>
147 </div> 147 </div>
148 148
149 - 149 +<script type="text/javascript">
  150 + $("#contrast_button" ).click(function() {
  151 + if (Cookies.get('contrast_check')) {
  152 + Cookies.remove('contrast_check')
  153 + location.reload()
  154 + }
  155 + else {
  156 + Cookies.set('contrast_check','anonymous')
  157 + location.reload()
  158 + }
  159 +
  160 + });
  161 +</script>
150 {% endblock%} 162 {% endblock%}
151 163
152 {% block footer %} 164 {% block footer %}