Merge pull request #607 from tiwariav/task/4378/navbar_logo_multisite
Task/4378 navbar content on non-cms pages
This commit is contained in:
commit
bf2797eccd
11 changed files with 106 additions and 25 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
next:
|
||||||
|
* #4378: [dcl cms] update CMS Integration to have different content for different domains
|
||||||
1.6.2: 2018-04-01:
|
1.6.2: 2018-04-01:
|
||||||
* bgfix: [dcl] Fix user activation email style; add/correct some DE text
|
* bgfix: [dcl] Fix user activation email style; add/correct some DE text
|
||||||
* #4373: [dcl] update footer menu for pw reset/login/signup/activation request pages
|
* #4373: [dcl] update footer menu for pw reset/login/signup/activation request pages
|
||||||
|
|
|
@ -4,7 +4,7 @@ from .cms_models import CMSIntegration
|
||||||
|
|
||||||
|
|
||||||
class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
|
class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
|
||||||
pass
|
list_display = ('name', 'domain')
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(CMSIntegration, CMSIntegrationAdmin)
|
admin.site.register(CMSIntegration, CMSIntegrationAdmin)
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
from cms.models.fields import PlaceholderField
|
||||||
from cms.models.pluginmodel import CMSPlugin
|
from cms.models.pluginmodel import CMSPlugin
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from djangocms_text_ckeditor.fields import HTMLField
|
from djangocms_text_ckeditor.fields import HTMLField
|
||||||
from filer.fields.image import FilerImageField
|
from filer.fields.image import FilerImageField
|
||||||
from cms.models.fields import PlaceholderField
|
|
||||||
|
|
||||||
|
|
||||||
class CMSIntegration(models.Model):
|
class CMSIntegration(models.Model):
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=100, unique=True, default='default',
|
max_length=100, default='default',
|
||||||
help_text=(
|
help_text=(
|
||||||
'A unique name for the Integration. This name will be used to '
|
'A unique name for the Integration. This name will be used to '
|
||||||
'fetch the Integration into pages'
|
'fetch the Integration into pages'
|
||||||
|
@ -20,6 +21,10 @@ class CMSIntegration(models.Model):
|
||||||
navbar_placeholder = PlaceholderField(
|
navbar_placeholder = PlaceholderField(
|
||||||
'datacenterlight_navbar', related_name='dcl-navbar-placeholder+'
|
'datacenterlight_navbar', related_name='dcl-navbar-placeholder+'
|
||||||
)
|
)
|
||||||
|
domain = models.ForeignKey(Site, null=True, blank=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = ('name', 'domain')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -6,8 +6,16 @@ class Command(BaseCommand):
|
||||||
help = '''Creates cms integration objects for datacenterlight'''
|
help = '''Creates cms integration objects for datacenterlight'''
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
obj, created = CMSIntegration.objects.get_or_create(name='default')
|
self.create_cms_integration()
|
||||||
|
|
||||||
|
def create_cms_integration(self, site=None):
|
||||||
|
obj, created = CMSIntegration.objects.get_or_create(
|
||||||
|
name='default', domain=site
|
||||||
|
)
|
||||||
|
domain_name = site.domain if site else 'All Sites'
|
||||||
if created:
|
if created:
|
||||||
print('created the default CMSIntegration object')
|
print('created the default CMSIntegration object for', domain_name)
|
||||||
else:
|
else:
|
||||||
print('default CMSIntegration object already exists')
|
print(
|
||||||
|
'default CMSIntegration object already exists for', domain_name
|
||||||
|
)
|
||||||
|
|
43
datacenterlight/migrations/0018_auto_20180403_1930.py
Normal file
43
datacenterlight/migrations/0018_auto_20180403_1930.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.4 on 2018-04-03 17:08
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
replaces = [('datacenterlight', '0018_auto_20180403_1930'), ('datacenterlight', '0019_auto_20180403_2054')]
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('datacenterlight', '0017_auto_20180329_0056'),
|
||||||
|
('sites', '0002_alter_domain_unique'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='dclcontactpluginmodel',
|
||||||
|
name='organization_name',
|
||||||
|
field=models.CharField(blank=True, default='ungleich glarus ag', max_length=100),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='dclfooterpluginmodel',
|
||||||
|
name='copyright_label',
|
||||||
|
field=models.CharField(blank=True, default='ungleich glarus ag', help_text='Name of the company alongside the copyright year', max_length=100),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='cmsintegration',
|
||||||
|
name='domain',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='sites.Site'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cmsintegration',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(default='default', help_text='A unique name for the Integration. This name will be used to fetch the Integration into pages', max_length=100),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='cmsintegration',
|
||||||
|
unique_together=set([('name', 'domain')]),
|
||||||
|
),
|
||||||
|
]
|
|
@ -74,6 +74,17 @@ a.list-group-item-danger.active:focus {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#logoWhite,
|
||||||
|
.navbar-transparent #logoBlack {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logoBlack,
|
||||||
|
.navbar-transparent #logoWhite {
|
||||||
|
display: block;
|
||||||
|
width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.navbar-right {
|
.navbar-right {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
.navbar-transparent #logoWhite {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-transparent #logoBlack {
|
||||||
|
display: block;
|
||||||
|
width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
.topnav .navbar-fixed-top .navbar-collapse {
|
.topnav .navbar-fixed-top .navbar-collapse {
|
||||||
max-height: 740px;
|
max-height: 740px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,17 +141,6 @@ textarea {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#logoWhite,
|
|
||||||
.navbar-transparent #logoBlack {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#logoBlack,
|
|
||||||
.navbar-transparent #logoWhite {
|
|
||||||
display: block;
|
|
||||||
width: 220px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-language {
|
.nav-language {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
{% if instance.logo_dark or instance.logo_light %}
|
{% if instance.logo_dark or instance.logo_light %}
|
||||||
<a href="{{ instance.logo_url|default:'/' }}" id="logoBlack" class="navbar-brand topnav"><img src="{{ instance.get_logo_dark }}"></a>
|
<a href="{{ instance.logo_url|default:'/' }}" id="logoBlack" class="navbar-brand"><img src="{{ instance.get_logo_dark }}"></a>
|
||||||
<a href="{{ instance.logo_url|default:'/' }}" id="logoWhite" class="navbar-brand topnav"><img src="{{ instance.get_logo_light }}"></a>
|
<a href="{{ instance.logo_url|default:'/' }}" id="logoWhite" class="navbar-brand"><img src="{{ instance.get_logo_light }}"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/" id="logoBlack" class="navbar-brand topnav"><img src="{% static 'datacenterlight/img/logo_black.svg' %}"></a>
|
<a href="/" id="logoBlack" class="navbar-brand"><img src="{% static 'datacenterlight/img/logo_black.svg' %}"></a>
|
||||||
<a href="/" id="logoWhite" class="navbar-brand topnav"><img src="{% static 'datacenterlight/img/logo_white.svg' %}"></a>
|
<a href="/" id="logoWhite" class="navbar-brand"><img src="{% static 'datacenterlight/img/logo_white.svg' %}"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="dcl-topnav">
|
<div class="collapse navbar-collapse" id="dcl-topnav">
|
||||||
|
|
14
datacenterlight/utils.py
Normal file
14
datacenterlight/utils.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
|
|
||||||
|
from .cms_models import CMSIntegration
|
||||||
|
|
||||||
|
|
||||||
|
def get_cms_integration(name):
|
||||||
|
current_site = Site.objects.get_current()
|
||||||
|
try:
|
||||||
|
cms_integration = CMSIntegration.objects.get(
|
||||||
|
name=name, domain=current_site
|
||||||
|
)
|
||||||
|
except CMSIntegration.DoesNotExist:
|
||||||
|
cms_integration = CMSIntegration.objects.get(name=name, domain=None)
|
||||||
|
return cms_integration
|
|
@ -24,7 +24,7 @@ from utils.stripe_utils import StripeUtils
|
||||||
from utils.tasks import send_plain_email_task
|
from utils.tasks import send_plain_email_task
|
||||||
from .forms import ContactForm
|
from .forms import ContactForm
|
||||||
from .models import VMTemplate
|
from .models import VMTemplate
|
||||||
from .cms_models import CMSIntegration
|
from .utils import get_cms_integration
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ class PaymentOrderView(FormView):
|
||||||
'site_url': reverse('datacenterlight:index'),
|
'site_url': reverse('datacenterlight:index'),
|
||||||
'login_form': HostingUserLoginForm(prefix='login_form'),
|
'login_form': HostingUserLoginForm(prefix='login_form'),
|
||||||
'billing_address_form': billing_address_form,
|
'billing_address_form': billing_address_form,
|
||||||
'cms_integration': CMSIntegration.objects.get(name='default')
|
'cms_integration': get_cms_integration('default')
|
||||||
})
|
})
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ class OrderConfirmationView(DetailView):
|
||||||
'billing_address_data': (
|
'billing_address_data': (
|
||||||
request.session.get('billing_address_data')
|
request.session.get('billing_address_data')
|
||||||
),
|
),
|
||||||
'cms_integration': CMSIntegration.objects.get(name='default')
|
'cms_integration': get_cms_integration('default')
|
||||||
}
|
}
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue