diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 6b8710a7..00000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -.git diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 50b81cbb..00000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM python:3.10.0-alpine3.15 - -WORKDIR /usr/src/app - -RUN apk add --update --no-cache \ - git \ - build-base \ - openldap-dev \ - python3-dev \ - libpq-dev \ - && rm -rf /var/cache/apk/* - -# FIX https://github.com/python-ldap/python-ldap/issues/432 -RUN echo 'INPUT ( libldap.so )' > /usr/lib/libldap_r.so - -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt -COPY ./ . diff --git a/Makefile b/Makefile index 68ff014e..67c0c15b 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,6 @@ help: @echo ' make rsync_upload ' @echo ' make install_debian_packages ' -buildimage: - docker build -t dynamicweb:$$(git describe) . - -releaseimage: buildimage - ./release.sh - collectstatic: $(PY?) $(BASEDIR)/manage.py collectstatic diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 52b4f19f..ffecbf0b 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -1,6 +1,7 @@ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from django.conf import settings +from django.utils.translation import ugettext_lazy as _ from .cms_models import ( DCLBannerItemPluginModel, DCLBannerListPluginModel, DCLContactPluginModel, @@ -10,7 +11,9 @@ from .cms_models import ( DCLSectionPromoPluginModel, DCLCalculatorPluginModel ) from .models import VMTemplate -from datacenterlight.utils import clear_all_session_vars +from datacenterlight.utils import clear_all_session_vars, get_ip_address + +import ipaddress @plugin_pool.register_plugin @@ -170,6 +173,25 @@ class DCLContactPlugin(CMSPluginBase): render_template = "datacenterlight/cms/contact.html" cache = False + def render(self, context, instance, placeholder): + context = super(DCLContactPlugin, self).render( + context, instance, placeholder + ) + request_ip_address = get_ip_address(context['request']) + request_v4v6 = '' + if (type(ipaddress.ip_address(request_ip_address)) == + ipaddress.IPv4Address): + request_v4v6 = 'IPv4' + elif (type(ipaddress.ip_address(request_ip_address)) == + ipaddress.IPv6Address): + request_v4v6 = 'IPv6' + context['ip_address_label_title'] = _( + "You are requesting this website from " + "{ip_address}.".format(ip_address=request_ip_address)) + context['ip_address_label'] = _( + "Enter '{v4v6}':".format(v4v6=request_v4v6)) + return context + @plugin_pool.register_plugin class DCLFooterPlugin(CMSPluginBase): diff --git a/datacenterlight/forms.py b/datacenterlight/forms.py index b697f694..d5b6f814 100644 --- a/datacenterlight/forms.py +++ b/datacenterlight/forms.py @@ -1,9 +1,42 @@ from django import forms +from django.utils.translation import ugettext_lazy as _ +from datacenterlight.utils import get_ip_address + +import logging from .models import ContactUs +import ipaddress +logger = logging.getLogger(__name__) + class ContactForm(forms.ModelForm): class Meta: - fields = ['name', 'email', 'message'] + fields = ['name', 'email', 'message', 'ip_address'] model = ContactUs + labels = { + "ip_address": _("You are requesting this website from " + "{{ip_address}}. Enter 'IPv{{v4v6}}':".format( + ip_address='test', v4v6='4' + )) + } + + def __init__(self, *args, **kwargs): + self.request = kwargs.pop('request', None) + super(ContactForm, self).__init__(*args, **kwargs) + self.fields['ip_address'] = forms.CharField(required=True) + + def clean_ip_address(self): + input_ip_address_text = self.cleaned_data.get('ip_address') + request_ip_address = get_ip_address(self.request) + ip_address_type_text = 'ipv4' + if (type(ipaddress.ip_address(request_ip_address)) + == ipaddress.IPv4Address): + ip_address_type_text = 'ipv4' + elif (type(ipaddress.ip_address(request_ip_address)) + == ipaddress.IPv6Address): + ip_address_type_text = 'ipv6' + if input_ip_address_text.strip().lower() == ip_address_type_text: + return request_ip_address + else: + raise forms.ValidationError(_("Input correct IP address type")) diff --git a/datacenterlight/migrations/0032_contactus_ip_address.py b/datacenterlight/migrations/0032_contactus_ip_address.py new file mode 100644 index 00000000..836fcc10 --- /dev/null +++ b/datacenterlight/migrations/0032_contactus_ip_address.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2021-02-11 10:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0031_vmpricing_stripe_coupon_id'), + ] + + operations = [ + migrations.AddField( + model_name='contactus', + name='ip_address', + field=models.TextField(default='', null=True), + ), + ] diff --git a/datacenterlight/models.py b/datacenterlight/models.py index 64d785a2..a075fd66 100644 --- a/datacenterlight/models.py +++ b/datacenterlight/models.py @@ -118,6 +118,7 @@ class ContactUs(models.Model): name = models.CharField(max_length=250) email = models.CharField(max_length=250) message = models.TextField() + ip_address = models.TextField(default='', null=True) field = models.DateTimeField(auto_now_add=True) def __str__(self): diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index 899b506f..9c98b729 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -195,7 +195,7 @@ def handle_metadata_and_emails(order_id, vm_id, manager, user, specs, email_data = { 'subject': settings.DCL_TEXT + " Order from %s" % context['email'], 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS, - 'to': ['dcl-orders@ungleich.ch'], + 'to': ['info@ungleich.ch'], 'body': "\n".join( ["%s=%s" % (k, v) for (k, v) in context.items()]), 'reply_to': [context['email']], @@ -233,4 +233,4 @@ def handle_metadata_and_emails(order_id, vm_id, manager, user, specs, logger.debug("New VM ID is {vm_id}".format(vm_id=vm_id)) if vm_id > 0: - get_or_create_vm_detail(custom_user, manager, vm_id) + get_or_create_vm_detail(custom_user, manager, vm_id) \ No newline at end of file diff --git a/datacenterlight/templates/datacenterlight/contact_form.html b/datacenterlight/templates/datacenterlight/contact_form.html index 87848ff2..afaf7144 100644 --- a/datacenterlight/templates/datacenterlight/contact_form.html +++ b/datacenterlight/templates/datacenterlight/contact_form.html @@ -26,7 +26,7 @@
- +
{{contact_form.name.errors}}
@@ -34,7 +34,7 @@
- +
{{contact_form.email.errors}}
@@ -42,11 +42,19 @@
- +
{{contact_form.message.errors}}
+
 
{{ ip_address_label_title }}{{contact_form.message.errors}}
+
+ +
+ +
{{contact_form.ip_address.errors}}
+
+
{% trans "Sorry, there was an unexpected error. Kindly retry." %}
diff --git a/datacenterlight/utils.py b/datacenterlight/utils.py index 4e8094c0..435de23c 100644 --- a/datacenterlight/utils.py +++ b/datacenterlight/utils.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) eu_countries = ['at', 'be', 'bg', 'ch', 'cy', 'cz', 'hr', 'dk', 'ee', 'fi', 'fr', 'mc', 'de', 'gr', 'hu', 'ie', 'it', - 'lv', 'lu', 'mt', 'nl', 'pl', 'pt', 'ro','sk', 'si', 'es', + 'lv', 'lu', 'mt', 'nl', 'po', 'pt', 'ro','sk', 'si', 'es', 'se', 'gb'] @@ -303,3 +303,12 @@ def create_tax_id(stripe_customer_id, billing_address_id, type, billing_address.vat_validation_status = tax_id_obj.verification.status billing_address.save() return tax_id_obj + + +def get_ip_address(request): + x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') + if x_forwarded_for: + ip = x_forwarded_for.split(',')[-1].strip() + else: + ip = request.META.get('REMOTE_ADDR') + return ip \ No newline at end of file diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 5bf68e0a..ed2437ad 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -49,11 +49,30 @@ class ContactUsView(FormView): template_name = "datacenterlight/contact_form.html" form_class = ContactForm + def get_form_kwargs(self): + kw = super(ContactUsView, self).get_form_kwargs() + kw['request'] = self.request + return kw + def get(self, request, *args, **kwargs): return HttpResponseRedirect(reverse('datacenterlight:index')) def form_invalid(self, form): if self.request.is_ajax(): + logger.debug(form) + # request_ip_address = get_ip_address(self.request) + # request_v4v6 = '' + # if (type(ipaddress.ip_address(request_ip_address)) == + # ipaddress.IPv4Address): + # request_v4v6 = 'IPv4' + # elif (type(ipaddress.ip_address(request_ip_address)) == + # ipaddress.IPv6Address): + # request_v4v6 = 'IPv6' + # context['ip_address_label_title'] = _( + # "You are requesting this website from " + # "{ip_address}.".format(ip_address=request_ip_address)) + # context['ip_address_label'] = _( + # "Enter '{v4v6}':".format(v4v6=request_v4v6)) return self.render_to_response( self.get_context_data(contact_form=form)) else: @@ -1333,7 +1352,7 @@ def do_provisioning_generic( 'subject': (settings.DCL_TEXT + " Payment received from %s" % context['email']), 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS, - 'to': ['dcl-orders@ungleich.ch'], + 'to': ['info@ungleich.ch'], 'body': "\n".join( ["%s=%s" % (k, v) for (k, v) in context.items()]), 'reply_to': [context['email']], @@ -1507,7 +1526,7 @@ def do_provisioning(request, stripe_api_cus_id, card_details_response, 'subject': (settings.DCL_TEXT + " Payment received from %s" % context['email']), 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS, - 'to': ['dcl-orders@ungleich.ch'], + 'to': ['info@ungleich.ch'], 'body': "\n".join( ["%s=%s" % (k, v) for (k, v) in context.items()]), 'reply_to': [context['email']], diff --git a/digitalglarus/locale/de/LC_MESSAGES/django.po b/digitalglarus/locale/de/LC_MESSAGES/django.po index ef7a46b5..ec96f5dc 100644 --- a/digitalglarus/locale/de/LC_MESSAGES/django.po +++ b/digitalglarus/locale/de/LC_MESSAGES/django.po @@ -376,6 +376,8 @@ msgid "" " digitalglarus.ch
\n" " hack4lgarus.ch
\n" " ipv6onlyhosting.com
\n" +" ipv6onlyhosting.ch
\n" +" ipv6onlyhosting.net
\n" " django-hosting.ch
\n" " rails-hosting.ch
\n" " node-hosting.ch
\n" @@ -634,8 +636,8 @@ msgstr "" "Internetangebot der ungleich glarus ag, welches unter den nachfolgenden " "Domains erreichbar ist:

ungleich.ch
datacenterlight.ch
devuanhosting.com
devuanhosting.ch
digitalglarus.ch
hack4lgarus." -"ch
ipv6onlyhosting.com
django-hosting.ch
rails-hosting.ch" -"
node-hosting.ch
blog." +"ch
ipv6onlyhosting.com
ipv6onlyhosting.ch
ipv6onlyhosting.net
django-hosting.ch
rails-hosting.ch
node-hosting.ch
blog." "ungleich.ch

Der Datenschutzbeauftragte des Verantwortlichen ist:

Sanghee Kim
ungleich glarus ag
Bahnhofstrasse 1
8783 " "Linthal (CH)
E-Mail: sanghee." @@ -836,4 +838,3 @@ msgstr "" #~ msgid "index/?$" #~ msgstr "index/?$" - diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 62fe2897..03013ea5 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -631,6 +631,8 @@ GOOGLE_ANALYTICS_PROPERTY_IDS = { 'datacenterlight.ch': 'UA-62285904-8', 'devuanhosting.ch': 'UA-62285904-9', 'devuanhosting.com': 'UA-62285904-9', + 'ipv6onlyhosting.ch': 'UA-62285904-10', + 'ipv6onlyhosting.net': 'UA-62285904-10', 'ipv6onlyhosting.com': 'UA-62285904-10', 'comic.ungleich.ch': 'UA-62285904-13', '127.0.0.1:8000': 'localhost', diff --git a/dynamicweb/settings/prod.py b/dynamicweb/settings/prod.py index 0590ca27..445748ad 100644 --- a/dynamicweb/settings/prod.py +++ b/dynamicweb/settings/prod.py @@ -28,7 +28,9 @@ ALLOWED_HOSTS = [ ".devuanhosting.ch", ".devuanhosting.com", ".digitalezukunft.ch", + ".ipv6onlyhosting.ch", ".ipv6onlyhosting.com", + ".ipv6onlyhosting.net", ".digitalglarus.ch", ".hack4glarus.ch", ".xn--nglarus-n2a.ch" diff --git a/hosting/views.py b/hosting/views.py index e2f6e13b..ac5f81de 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1315,8 +1315,7 @@ class InvoiceListView(LoginRequiredMixin, TemplateView): logger.debug("User does not exist") cu = self.request.user invs = stripe.Invoice.list(customer=cu.stripecustomer.stripe_id, - count=100, - status='paid') + count=100) paginator = Paginator(invs.data, 10) try: invs_page = paginator.page(page) @@ -1911,7 +1910,7 @@ class VirtualMachineView(LoginRequiredMixin, View): 'subject': ("Deleted " if response['status'] else "ERROR deleting ") + admin_msg_sub, 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS, - 'to': ['dcl-orders@ungleich.ch'], + 'to': ['info@ungleich.ch'], 'body': "\n".join( ["%s=%s" % (k, v) for (k, v) in admin_email_body.items()]), } diff --git a/release.sh b/release.sh deleted file mode 100755 index 535cc7d4..00000000 --- a/release.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Nico Schottelius, 2021-12-17 - -current=$(git describe --dirty) -last_tag=$(git describe --tags --abbrev=0) -registry=harbor.ungleich.svc.p10.k8s.ooo/ungleich-public -image_url=$registry/dynamicweb:${current} - -if echo $current | grep -q -e 'dirty$'; then - echo Refusing to release a dirty tree build - exit 1 -fi - -if [ "$current" != "$last_tag" ]; then - echo "Last tag ($last_tag) is not current version ($current)" - echo "Only release proper versions" - exit 1 -fi - -docker tag dynamicweb:${current} ${image_url} -docker push ${image_url} diff --git a/requirements.txt b/requirements.txt index 8d04a189..e7769a7e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ django-compressor==2.0 django-debug-toolbar==1.4 python-dotenv==0.10.3 django-extensions==1.6.7 -django-filer==2.1.2 +django-filer==1.2.0 django-filter==0.13.0 django-formtools==1.0 django-guardian==1.4.4 @@ -83,7 +83,7 @@ stripe==2.41.0 wheel==0.29.0 django-admin-honeypot==1.0.0 coverage==4.3.4 -git+https://github.com/ungleich/python-oca.git#egg=oca +git+https://github.com/ungleich/python-oca.git#egg=python-oca djangorestframework==3.6.3 flake8==3.3.0 python-memcached==1.58 diff --git a/templates/gdpr/gdpr_banner.html b/templates/gdpr/gdpr_banner.html index f927f8ee..7e9f5c7f 100644 --- a/templates/gdpr/gdpr_banner.html +++ b/templates/gdpr/gdpr_banner.html @@ -134,6 +134,8 @@ digitalglarus.ch
hack4lgarus.ch
ipv6onlyhosting.com
+ ipv6onlyhosting.ch
+ ipv6onlyhosting.net
django-hosting.ch
rails-hosting.ch
node-hosting.ch
diff --git a/utils/ldap_manager.py b/utils/ldap_manager.py index d40e931f..ee190732 100644 --- a/utils/ldap_manager.py +++ b/utils/ldap_manager.py @@ -3,7 +3,6 @@ import hashlib import random import ldap3 import logging -import unicodedata from django.conf import settings @@ -102,7 +101,7 @@ class LdapManager: "uidNumber": [str(uidNumber)], "gidNumber": [str(settings.LDAP_CUSTOMER_GROUP_ID)], "loginShell": ["/bin/bash"], - "homeDirectory": ["/home/{}".format(unicodedata.normalize('NFKD', user).encode('ascii','ignore'))], + "homeDirectory": ["/home/{}".format(user).encode("utf-8")], "mail": email.encode("utf-8"), "userPassword": [self._ssha_password( password.encode("utf-8")