From d843c34d6825afc2572aba2960b96a6025c2e11c Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Tue, 3 Apr 2018 22:41:29 +0530
Subject: [PATCH 1/8] modified cms integrate to support separate content for
 each domain

---
 datacenterlight/admin.py                      |  2 +-
 datacenterlight/cms_models.py                 |  9 +++-
 .../management/commands/cmsintegrate.py       | 15 +++++--
 .../migrations/0018_auto_20180403_1930.py     | 43 +++++++++++++++++++
 .../static/datacenterlight/css/common.css     | 11 +++++
 .../static/datacenterlight/css/hosting.css    |  9 ++++
 .../datacenterlight/css/landing-page.css      | 11 -----
 .../templates/datacenterlight/cms/navbar.html |  8 ++--
 datacenterlight/utils.py                      | 14 ++++++
 datacenterlight/views.py                      |  7 +--
 10 files changed, 105 insertions(+), 24 deletions(-)
 create mode 100644 datacenterlight/migrations/0018_auto_20180403_1930.py
 create mode 100644 datacenterlight/utils.py

diff --git a/datacenterlight/admin.py b/datacenterlight/admin.py
index 974006a6..acb93fff 100644
--- a/datacenterlight/admin.py
+++ b/datacenterlight/admin.py
@@ -4,7 +4,7 @@ from .cms_models import CMSIntegration
 
 
 class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
-    pass
+    list_display = ('name', 'domain')
 
 
 admin.site.register(CMSIntegration, CMSIntegrationAdmin)
diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py
index 2f63c150..9eb55e0c 100644
--- a/datacenterlight/cms_models.py
+++ b/datacenterlight/cms_models.py
@@ -1,14 +1,15 @@
+from cms.models.fields import PlaceholderField
 from cms.models.pluginmodel import CMSPlugin
+from django.contrib.sites.models import Site
 from django.db import models
 from django.utils.safestring import mark_safe
 from djangocms_text_ckeditor.fields import HTMLField
 from filer.fields.image import FilerImageField
-from cms.models.fields import PlaceholderField
 
 
 class CMSIntegration(models.Model):
     name = models.CharField(
-        max_length=100, unique=True, default='default',
+        max_length=100, default='default',
         help_text=(
             'A unique name for the Integration. This name will be used to '
             'fetch the Integration into pages'
@@ -20,6 +21,10 @@ class CMSIntegration(models.Model):
     navbar_placeholder = PlaceholderField(
         'datacenterlight_navbar', related_name='dcl-navbar-placeholder+'
     )
+    domain = models.ForeignKey(Site, null=True, blank=True)
+
+    class Meta:
+        unique_together = ('name', 'domain')
 
     def __str__(self):
         return self.name
diff --git a/datacenterlight/management/commands/cmsintegrate.py b/datacenterlight/management/commands/cmsintegrate.py
index 5b4f72d2..66691649 100644
--- a/datacenterlight/management/commands/cmsintegrate.py
+++ b/datacenterlight/management/commands/cmsintegrate.py
@@ -1,3 +1,4 @@
+from django.contrib.sites.models import Site
 from django.core.management.base import BaseCommand
 from datacenterlight.cms_models import CMSIntegration
 
@@ -6,8 +7,16 @@ class Command(BaseCommand):
     help = '''Creates cms integration objects for datacenterlight'''
 
     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:
-            print('created the default CMSIntegration object')
+            print('created the default CMSIntegration object for', domain_name)
         else:
-            print('default CMSIntegration object already exists')
+            print(
+                'default CMSIntegration object already exists for', domain_name
+            )
diff --git a/datacenterlight/migrations/0018_auto_20180403_1930.py b/datacenterlight/migrations/0018_auto_20180403_1930.py
new file mode 100644
index 00000000..5c418898
--- /dev/null
+++ b/datacenterlight/migrations/0018_auto_20180403_1930.py
@@ -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')]),
+        ),
+    ]
diff --git a/datacenterlight/static/datacenterlight/css/common.css b/datacenterlight/static/datacenterlight/css/common.css
index cddb0f69..88db9376 100644
--- a/datacenterlight/static/datacenterlight/css/common.css
+++ b/datacenterlight/static/datacenterlight/css/common.css
@@ -74,6 +74,17 @@ a.list-group-item-danger.active:focus {
   padding: 10px;
 }
 
+#logoWhite,
+.navbar-transparent #logoBlack {
+  display: none;
+}
+
+#logoBlack,
+.navbar-transparent #logoWhite {
+  display: block;
+  width: 220px;
+}
+
 @media (min-width: 768px) {
   .navbar-right {
     margin-right: 10px;
diff --git a/datacenterlight/static/datacenterlight/css/hosting.css b/datacenterlight/static/datacenterlight/css/hosting.css
index 7764f0c3..b4c5909c 100644
--- a/datacenterlight/static/datacenterlight/css/hosting.css
+++ b/datacenterlight/static/datacenterlight/css/hosting.css
@@ -1,3 +1,12 @@
+.navbar-transparent #logoWhite {
+  display: none;
+}
+
+.navbar-transparent #logoBlack {
+  display: block;
+  width: 220px;
+}
+
 .topnav .navbar-fixed-top .navbar-collapse {
   max-height: 740px;
 }
diff --git a/datacenterlight/static/datacenterlight/css/landing-page.css b/datacenterlight/static/datacenterlight/css/landing-page.css
index 38e84a59..41c5a42f 100755
--- a/datacenterlight/static/datacenterlight/css/landing-page.css
+++ b/datacenterlight/static/datacenterlight/css/landing-page.css
@@ -141,17 +141,6 @@ textarea {
   color: #fff;
 }
 
-#logoWhite,
-.navbar-transparent #logoBlack {
-  display: none;
-}
-
-#logoBlack,
-.navbar-transparent #logoWhite {
-  display: block;
-  width: 220px;
-}
-
 .nav-language {
   position: relative;
 }
diff --git a/datacenterlight/templates/datacenterlight/cms/navbar.html b/datacenterlight/templates/datacenterlight/cms/navbar.html
index bfa3e086..ae6643aa 100644
--- a/datacenterlight/templates/datacenterlight/cms/navbar.html
+++ b/datacenterlight/templates/datacenterlight/cms/navbar.html
@@ -11,11 +11,11 @@
       <span class="icon-bar"></span>
     </button>
     {% 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="logoWhite" class="navbar-brand topnav"><img src="{{ instance.get_logo_light }}"></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"><img src="{{ instance.get_logo_light }}"></a>
     {% else %}
-      <a href="/" id="logoBlack" class="navbar-brand topnav"><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="logoBlack" class="navbar-brand"><img src="{% static 'datacenterlight/img/logo_black.svg' %}"></a>
+      <a href="/" id="logoWhite" class="navbar-brand"><img src="{% static 'datacenterlight/img/logo_white.svg' %}"></a>
     {% endif %}
   </div>
   <div class="collapse navbar-collapse" id="dcl-topnav">
diff --git a/datacenterlight/utils.py b/datacenterlight/utils.py
new file mode 100644
index 00000000..2efade8e
--- /dev/null
+++ b/datacenterlight/utils.py
@@ -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
diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index e2241a17..371098ab 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -9,6 +9,7 @@ from django.core.exceptions import ValidationError
 from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect, HttpResponse
 from django.shortcuts import render
+
 from django.utils.translation import get_language, ugettext_lazy as _
 from django.views.decorators.cache import cache_control
 from django.views.generic import FormView, CreateView, DetailView
@@ -24,7 +25,7 @@ from utils.stripe_utils import StripeUtils
 from utils.tasks import send_plain_email_task
 from .forms import ContactForm
 from .models import VMTemplate
-from .cms_models import CMSIntegration
+from .utils import get_cms_integration
 
 logger = logging.getLogger(__name__)
 
@@ -220,7 +221,7 @@ class PaymentOrderView(FormView):
             'site_url': reverse('datacenterlight:index'),
             'login_form': HostingUserLoginForm(prefix='login_form'),
             'billing_address_form': billing_address_form,
-            'cms_integration': CMSIntegration.objects.get(name='default')
+            'cms_integration': get_cms_integration('default')
         })
         return context
 
@@ -358,7 +359,7 @@ class OrderConfirmationView(DetailView):
             '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)
 

From fe3fcb5100f571965f55f1acebadffa2dfe6cc4e Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Tue, 3 Apr 2018 22:51:04 +0530
Subject: [PATCH 2/8] flake8 fix

---
 datacenterlight/management/commands/cmsintegrate.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/datacenterlight/management/commands/cmsintegrate.py b/datacenterlight/management/commands/cmsintegrate.py
index 66691649..206248d2 100644
--- a/datacenterlight/management/commands/cmsintegrate.py
+++ b/datacenterlight/management/commands/cmsintegrate.py
@@ -1,4 +1,3 @@
-from django.contrib.sites.models import Site
 from django.core.management.base import BaseCommand
 from datacenterlight.cms_models import CMSIntegration
 

From ae2dea993decaddc45427a51658fa6c3d25eee28 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Wed, 4 Apr 2018 02:27:30 +0530
Subject: [PATCH 3/8] remove whitespace

---
 datacenterlight/views.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/datacenterlight/views.py b/datacenterlight/views.py
index 371098ab..af3b774c 100644
--- a/datacenterlight/views.py
+++ b/datacenterlight/views.py
@@ -9,7 +9,6 @@ from django.core.exceptions import ValidationError
 from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect, HttpResponse
 from django.shortcuts import render
-
 from django.utils.translation import get_language, ugettext_lazy as _
 from django.views.decorators.cache import cache_control
 from django.views.generic import FormView, CreateView, DetailView

From 7c13def3a29c88eea3ae62592b4e4cd4b317630f Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Wed, 4 Apr 2018 17:55:19 +0530
Subject: [PATCH 4/8] header btn link fix

---
 datacenterlight/static/datacenterlight/js/main.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/datacenterlight/static/datacenterlight/js/main.js b/datacenterlight/static/datacenterlight/js/main.js
index dc5a9108..6753695c 100644
--- a/datacenterlight/static/datacenterlight/js/main.js
+++ b/datacenterlight/static/datacenterlight/js/main.js
@@ -113,10 +113,10 @@
             } else if (href) {
                 var path = $(this).prop('href').split('#');
                 var currentPath = window.location.origin + window.location.pathname;
-                if (!path[1]) {
-                    window.location = href;
-                } else if (currentPath == path[0]) {
+                if (currentPath == path[0] && path[1]) {
                     scrollToElement('#' + path[1]);
+                } else {
+                    window.location = href;
                 }
             }
         });

From c5dba114df147152bc055bac122fdcbe734c610b Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Wed, 4 Apr 2018 18:26:19 +0530
Subject: [PATCH 5/8] update changelog

---
 Changelog | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 899849ff..de1c0d8a 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,5 @@
+next:
+    * #4378: [dcl cms] update CMS Integration to have different content for different domains
 1.6.2: 2018-04-01:
     * 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
@@ -70,7 +72,7 @@
     * [cms] Introduce UngleichHeaderBackgroundImageAndTextSliderPlugin that allows to have scrolling images and texts
     * [cms] Remove <p> tag for ungleich cms customer item template
 1.2.12: 2017-12-09
-    * #3594: [digitalglarus] Remove white scroll bar on the right in mobile    
+    * #3594: [digitalglarus] Remove white scroll bar on the right in mobile
     * #3905: [ungleich] Update ungleich.ch header into a slider
     * #3968: [ungleich] Fix navbar logo alignment
     *        [all] Enable logging custom modules

From 80f4ac52e87ca44331b37c0ad3c4fc27f8b338a3 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Wed, 4 Apr 2018 18:36:45 +0530
Subject: [PATCH 6/8] update changelog

---
 Changelog | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 899849ff..86a30b00 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,5 @@
+next:
+    * bgfix: [cms] header btn external link fix
 1.6.2: 2018-04-01:
     * 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
@@ -70,7 +72,7 @@
     * [cms] Introduce UngleichHeaderBackgroundImageAndTextSliderPlugin that allows to have scrolling images and texts
     * [cms] Remove <p> tag for ungleich cms customer item template
 1.2.12: 2017-12-09
-    * #3594: [digitalglarus] Remove white scroll bar on the right in mobile    
+    * #3594: [digitalglarus] Remove white scroll bar on the right in mobile
     * #3905: [ungleich] Update ungleich.ch header into a slider
     * #3968: [ungleich] Fix navbar logo alignment
     *        [all] Enable logging custom modules

From 5cb51db6d703192bfb51d96400bb03471534a487 Mon Sep 17 00:00:00 2001
From: PCoder <purple.coder@yahoo.co.uk>
Date: Thu, 5 Apr 2018 23:31:47 +0200
Subject: [PATCH 7/8] Update .travis.yml

Add code to compile .po files before beginning tests
---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 6a3cca25..3a3d7027 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,6 +9,7 @@ env:
 install: "pip install -r requirements.txt"
 script:
 - flake8
+- python manage.py compilemessages
 - python manage.py test -v 3
 # - coverage run --source='.' manage.py test dynamicweb -v 3
 # - coverage report

From 1e81587551a9cdad583690320b1654151960e719 Mon Sep 17 00:00:00 2001
From: Arvind Tiwari <tiwariav@gmail.com>
Date: Fri, 6 Apr 2018 03:20:44 +0530
Subject: [PATCH 8/8] Update Changelog

---
 Changelog | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 806d56ff..811bc44c 100644
--- a/Changelog
+++ b/Changelog
@@ -1,7 +1,7 @@
-next:
-    * bgfix: [cms] header btn external link fix
+1.6.3: 2018-04-05
+    * #4377: [cms] header btn external link fix
     * #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
     * #4373: [dcl] update footer menu for pw reset/login/signup/activation request pages
 1.6.1: 2018-03-28