Commit 56df8ae1 authored by David Seaward's avatar David Seaward

round off expiry label (rather than floor)

* this is so very first credit doesn't appear short (29 days rather than 30)
* also added DEBUG flag to skip activation command when activation is not being tested (e.g. when developing/testing on localhost)
parent ecff9e9f
......@@ -6,6 +6,7 @@ SITE_TITLE = Title
SITE_BYLINE = Example byline
SITE_DOMAIN = example.com
DEBUG = True
DEBUG_SKIP_ACTIVATION_COMMAND = True
ALLOWED_HOSTS = localhost
STATIC_ROOT = /var/opt/purist/account/static
REGISTRATION_OPEN = True
......
......@@ -61,12 +61,11 @@ class Limit(models.Model):
def timedelta_to_daystring(self, delta):
single_day = 60 * 60 * 24
days = int(delta.total_seconds() / single_day)
days = int(round(delta.total_seconds() / single_day))
return str(days) + " days"
def tunnel_credit_label(self):
label = "-"
has_zero = self.expiry_date is None and self.time_total == 0
has_credit_only = self.expiry_date is None and self.time_total > 0
has_valid_expiry = self.expiry_date is not None and self.time_total == 0
......
......@@ -166,6 +166,11 @@ def activate(ssh, limit, credit_timedelta):
limit.expiry_date = timezone.now() + credit_timedelta
limit.is_active = True
# skip activation command if we are debugging
if settings.DEBUG_SKIP_ACTIVATION_COMMAND:
limit.save()
return
if limit.service == "TUNNEL":
managed_exec(ssh, "./create_new_ovpn_config --generate %s" % (limit.user.get_identity(),))
......
......@@ -23,6 +23,7 @@ SECRET_KEY = secret_config("DJANGO_SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config("DEBUG", cast=bool)
DEBUG_SKIP_ACTIVATION_COMMAND = config("DEBUG_SKIP_ACTIVATION_COMMAND", cast=bool)
# Required if DEBUG is False
ALLOWED_HOSTS = config("ALLOWED_HOSTS", cast=Csv())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment