From 5c8db8b5a3e363be63f21700149ef5891410374c Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Mon, 28 Apr 2014 20:16:48 +0530 Subject: Oscad workshop notification added. --- forums/settings.py | 5 ++++- static/website/css/nice-bar.css | 4 ++-- static/website/templates/base.html | 13 +++++++++++++ website/templatetags/nice_bar.py | 25 +++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 website/templatetags/nice_bar.py diff --git a/forums/settings.py b/forums/settings.py index be17520..406ac21 100644 --- a/forums/settings.py +++ b/forums/settings.py @@ -185,7 +185,10 @@ LOGGING = { AUTH_USER_MODEL = 'drupal_auth.Users' AUTHENTICATION_BACKENDS = ( 'drupal_auth.backends.DrupalAuthBackend', ) DATABASE_ROUTERS = ['drupal_auth.routers.DrupalAuthRouter'] -TEMPLATE_CONTEXT_PROCESSORS += ('website.context_processors.admin_processor', ) +TEMPLATE_CONTEXT_PROCESSORS += ( + 'django.core.context_processors.request', + 'website.context_processors.admin_processor', +) COMPRESS_ROOT = PROJECT_DIR + "/static/" COMPRESS_ENABLED = True diff --git a/static/website/css/nice-bar.css b/static/website/css/nice-bar.css index 6159b09..9294c7e 100644 --- a/static/website/css/nice-bar.css +++ b/static/website/css/nice-bar.css @@ -1,8 +1,8 @@ .nice-bar { display: none; width: 100%; - background: #70a865; - border-bottom: 3px solid #27ae60; + background: #0074D9; + border-bottom: 3px solid #ffffff; font-size: 0.85em; } .nice-bar .nice-text { diff --git a/static/website/templates/base.html b/static/website/templates/base.html index 172c901..d0697dd 100644 --- a/static/website/templates/base.html +++ b/static/website/templates/base.html @@ -7,9 +7,21 @@ + {% endcompress %} + {% load nice_bar %} + {% if request|is_nice_bar_visible %} +
+

+ One day Oscad workshop on 10th May 2014. + View more details about the workshop. + Click here for registration. + x +

+
+ {% endif %}
@@ -111,6 +123,7 @@ + {% block javascript %} {% endblock %} diff --git a/website/templatetags/nice_bar.py b/website/templatetags/nice_bar.py new file mode 100644 index 0000000..f7fd78c --- /dev/null +++ b/website/templatetags/nice_bar.py @@ -0,0 +1,25 @@ +import re + +from django import template + +from website.models import Question, Answer + +register = template.Library() + +# Showing/Hiding nice-bar on pages +def is_nice_bar_visible(request): + if request.path == '/': + return True + elif "Oscad" in request.path: + return True + elif "/question/" in request.path: + try: + question_id = request.path[1:-1].split('/') + question_id = int(question_id[1]) + question = Question.objects.get(pk=question_id) + if question.category == "Oscad": + return True + except: + return False + return False +register.filter('is_nice_bar_visible', is_nice_bar_visible) -- cgit