Compare commits
21 Commits
requiremen
...
master
Author | SHA1 | Date |
---|---|---|
app@dynamicweb-production | 92cfe71bbe | |
pcoder116 | 97d70cc5fd | |
PCoder | c4f6780a0e | |
pcoder116 | 0679a47eea | |
Nico Schottelius | 8b08357d05 | |
Nico Schottelius | 8b06c2c6e9 | |
Nico Schottelius | 26f3a1881d | |
nico14571 | dee2b1a90c | |
PCoder | 9e98125b13 | |
PCoder | 8d13629c8b | |
PCoder | b6ff2b62c1 | |
PCoder | 893c816846 | |
PCoder | f178be8395 | |
Nico Schottelius | 0d7f10776c | |
Nico Schottelius | 4eb470df16 | |
app@dynamicweb-production | 6262432b7a | |
app@dynamicweb-production | bd4d81c286 | |
Nico Schottelius | 169dc6b1ee | |
PCoder | fdb790bac7 | |
PCoder | 6a374f7fa0 | |
PCoder | 10d2c25556 |
|
@ -1 +1,2 @@
|
|||
.git
|
||||
.env
|
||||
|
|
20
Dockerfile
20
Dockerfile
|
@ -1,4 +1,5 @@
|
|||
FROM python:3.10.0-alpine3.15
|
||||
# FROM python:3.10.0-alpine3.15
|
||||
FROM python:3.5-alpine3.12
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
@ -7,12 +8,25 @@ RUN apk add --update --no-cache \
|
|||
build-base \
|
||||
openldap-dev \
|
||||
python3-dev \
|
||||
libpq-dev \
|
||||
postgresql-dev \
|
||||
jpeg-dev \
|
||||
libxml2-dev \
|
||||
libxslt-dev \
|
||||
libmemcached-dev \
|
||||
zlib-dev \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
## For alpine 3.15 replace postgresql-dev with libpq-dev
|
||||
|
||||
# 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
|
||||
|
||||
# Pillow seems to need LIBRARY_PATH set as follows: (see: https://github.com/python-pillow/Pillow/issues/1763#issuecomment-222383534)
|
||||
RUN LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install --no-cache-dir -r requirements.txt"
|
||||
|
||||
COPY ./ .
|
||||
COPY entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh" ]
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "$0 imageversion [push]"
|
||||
echo "Version could be: $(git describe --always)"
|
||||
echo "If push is specified, also push to our harbor"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tagprefix=harbor.k8s.ungleich.ch/ungleich-public/dynamicweb
|
||||
version=$1; shift
|
||||
|
||||
tag=${tagprefix}:${version}
|
||||
|
||||
set -ex
|
||||
|
||||
docker build -t "${tag}" .
|
||||
|
||||
push=$1; shift
|
||||
|
||||
if [ "$push" ]; then
|
||||
docker push "${tag}"
|
||||
fi
|
|
@ -0,0 +1,54 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from datacenterlight.tasks import handle_metadata_and_emails
|
||||
from datacenterlight.models import StripePlan
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from membership.models import CustomUser
|
||||
from hosting.models import GenericProduct
|
||||
import logging
|
||||
import json
|
||||
import sys
|
||||
import stripe
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = '''Stripe plans created before version 3.4 saved the plan name like generic-{subscription_id}-amount. This
|
||||
command aims at replacing this with the actual product name
|
||||
'''
|
||||
|
||||
def handle(self, *args, **options):
|
||||
cnt = 0
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
'In Fix generic stripe plan product names'
|
||||
)
|
||||
)
|
||||
plans_to_change = StripePlan.objects.filter(stripe_plan_id__startswith='generic')
|
||||
for plan in plans_to_change:
|
||||
response = input("Press 'y' to continue: ")
|
||||
|
||||
# Check if the user entered 'y'
|
||||
if response.lower() == 'y':
|
||||
plan_name = plan.stripe_plan_id
|
||||
first_index_hyphen = plan_name.index("-") + 1
|
||||
product_id = plan_name[
|
||||
first_index_hyphen:(plan_name[first_index_hyphen:].index("-")) + first_index_hyphen]
|
||||
gp = GenericProduct.objects.get(id=product_id)
|
||||
if gp:
|
||||
cnt += 1
|
||||
# update stripe
|
||||
sp = stripe.Plan.retrieve(plan_name)
|
||||
pr = stripe.Product.retrieve(sp.product)
|
||||
pr.name = gp.product_name
|
||||
pr.save()
|
||||
# update local
|
||||
spl = StripePlan.objects.get(stripe_plan_id=plan_name)
|
||||
spl.stripe_plan_name = gp.product_name
|
||||
spl.save()
|
||||
print("%s. %s => %s" % (cnt, plan_name, gp.product_name))
|
||||
else:
|
||||
print("Invalid input. Please try again.")
|
||||
sys.exit()
|
||||
|
||||
print("Done")
|
|
@ -144,7 +144,7 @@ def get_line_item_from_stripe_invoice(invoice):
|
|||
""".format(
|
||||
vm_id=vm_id if vm_id > 0 else "",
|
||||
ip_addresses=mark_safe(get_ip_addresses(vm_id)) if vm_id > 0 else
|
||||
mark_safe(get_product_name(plan_name)),
|
||||
mark_safe(get_product_name(plan_name)) if plan_name.startswith("generic-") else plan_name,
|
||||
period=mark_safe("%s — %s" % (
|
||||
datetime.datetime.fromtimestamp(start_date).strftime('%Y-%m-%d'),
|
||||
datetime.datetime.fromtimestamp(end_date).strftime('%Y-%m-%d'))),
|
||||
|
@ -160,8 +160,7 @@ def get_product_name(plan_name):
|
|||
product_name = ""
|
||||
if plan_name and plan_name.startswith("generic-"):
|
||||
first_index_hyphen = plan_name.index("-") + 1
|
||||
product_id = plan_name[first_index_hyphen:
|
||||
(plan_name[first_index_hyphen:].index("-")) + first_index_hyphen]
|
||||
product_id = plan_name[first_index_hyphen:(plan_name[first_index_hyphen:].index("-")) + first_index_hyphen]
|
||||
try:
|
||||
product = GenericProduct.objects.get(id=product_id)
|
||||
product_name = product.product_name
|
||||
|
|
|
@ -42,6 +42,8 @@ from .utils import (
|
|||
get_cms_integration, create_vm, clear_all_session_vars, validate_vat_number
|
||||
)
|
||||
|
||||
from datacenterlight.templatetags.custom_tags import get_product_name
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -900,15 +902,21 @@ class OrderConfirmationView(DetailView, FormView):
|
|||
2
|
||||
)
|
||||
)
|
||||
plan_name = "generic-{0}-{1:.2f}".format(
|
||||
stripe_plan_id = "generic-{0}-{1:.2f}".format(
|
||||
request.session['generic_payment_details']['product_id'],
|
||||
amount_to_be_charged
|
||||
)
|
||||
stripe_plan_id = plan_name
|
||||
try:
|
||||
product = GenericProduct.objects.get(id=request.session['generic_payment_details']['product_id'])
|
||||
plan_name = product.product_name
|
||||
except Exception as ex:
|
||||
logger.debug("Error {}" % str(ex))
|
||||
plan_name = get_product_name(stripe_plan_id)
|
||||
recurring_interval = request.session['generic_payment_details']['recurring_interval']
|
||||
if recurring_interval == "year":
|
||||
plan_name = "{}-yearly".format(plan_name)
|
||||
stripe_plan_id = plan_name
|
||||
stripe_plan_id = "{}-yearly".format(stripe_plan_id)
|
||||
plan_name = "{} (yearly)".format(plan_name)
|
||||
logger.debug("Plan name = {}, Stripe Plan id = {}".format(plan_name, stripe_plan_id))
|
||||
else:
|
||||
template = request.session.get('template')
|
||||
specs = request.session.get('specs')
|
||||
|
|
|
@ -777,3 +777,9 @@ if DEBUG:
|
|||
from .local import * # flake8: noqa
|
||||
else:
|
||||
from .prod import * # flake8: noqa
|
||||
|
||||
# Try to load dynamic configuration, if it exists
|
||||
try:
|
||||
from .dynamic import * # flake8: noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -uex
|
||||
|
||||
cd /usr/src/app/
|
||||
cat > dynamicweb/settings/dynamic.py <<EOF
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': '${POSTGRES_DB}',
|
||||
'USER': '${POSTGRES_USER}',
|
||||
'PASSWORD': '${POSTGRES_PASSWORD}',
|
||||
'HOST': '${POSTGRES_HOST}',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
exec "$@"
|
|
@ -87,7 +87,7 @@
|
|||
<tbody>
|
||||
{% for ho, stripe_charge_data in invs_charge %}
|
||||
<tr>
|
||||
{{ ho | get_line_item_from_hosting_order_charge }}
|
||||
{{ ho.id | get_line_item_from_hosting_order_charge }}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -1544,7 +1544,12 @@ class VirtualMachinesPlanListView(LoginRequiredMixin, ListView):
|
|||
ordering = '-id'
|
||||
|
||||
def get_queryset(self):
|
||||
owner = self.request.user
|
||||
username = self.request.GET.get('username')
|
||||
if self.request.user.is_admin and username:
|
||||
user = CustomUser.objects.get(username=username)
|
||||
else:
|
||||
user = self.request.user
|
||||
owner = user
|
||||
manager = OpenNebulaManager(email=owner.username,
|
||||
password=owner.password)
|
||||
try:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue