From c9ac959ff6ab585cbf63c984f798c358d9afd034 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 25 Sep 2018 22:29:54 +0200 Subject: [PATCH] Change DCLNavbarPlugin to show login option only if set --- datacenterlight/cms_models.py | 4 ++++ ..._dclnavbarpluginmodel_show_login_option.py | 20 +++++++++++++++++++ .../templates/datacenterlight/cms/navbar.html | 18 +++++++++-------- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 datacenterlight/migrations/0025_dclnavbarpluginmodel_show_login_option.py diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index 62a7b312..69f45507 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -180,6 +180,10 @@ class DCLNavbarPluginModel(CMSPlugin): default=True, help_text='Select to include the language selection dropdown.' ) + show_login_option = models.BooleanField( + default=True, + help_text='Uncheck this if you do not want to show login/dashboard.' + ) def get_logo_dark(self): # used only if atleast one logo exists diff --git a/datacenterlight/migrations/0025_dclnavbarpluginmodel_show_login_option.py b/datacenterlight/migrations/0025_dclnavbarpluginmodel_show_login_option.py new file mode 100644 index 00000000..e9ec57ba --- /dev/null +++ b/datacenterlight/migrations/0025_dclnavbarpluginmodel_show_login_option.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-09-25 20:27 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0024_dclcalculatorpluginmodel_vm_templates_to_show'), + ] + + operations = [ + migrations.AddField( + model_name='dclnavbarpluginmodel', + name='show_login_option', + field=models.BooleanField(default=True, help_text='Uncheck this if you do not want to show login/dashboard.'), + ), + ] diff --git a/datacenterlight/templates/datacenterlight/cms/navbar.html b/datacenterlight/templates/datacenterlight/cms/navbar.html index ae6643aa..886a5009 100644 --- a/datacenterlight/templates/datacenterlight/cms/navbar.html +++ b/datacenterlight/templates/datacenterlight/cms/navbar.html @@ -35,14 +35,16 @@ {% endif %} {% endif %} - {% if not request.user.is_authenticated %} -
  • - {% trans "Login" %}   -
  • - {% else %} -
  • - {% trans "Dashboard" %} -
  • + {% if instance.show_login_option %} + {% if not request.user.is_authenticated %} +
  • + {% trans "Login" %}   +
  • + {% else %} +
  • + {% trans "Dashboard" %} +
  • + {% endif %} {% endif %} {% comment %}