Nudge non-paying users to paid (yellow banner, site-title)

This commit is contained in:
Klaas van Schelven
2024-11-11 14:04:50 +01:00
parent 043c3462c3
commit 47bf207db5
5 changed files with 64 additions and 2 deletions

View File

@@ -1,11 +1,27 @@
from datetime import timedelta
from django.utils import timezone
from bugsink.app_settings import get_settings, CB_ANYBODY
from phonehome.models import Installation
def useful_settings_processor(request):
installation = Installation.objects.get()
nag_7 = installation.created_at < timezone.now() - timedelta(days=7)
nag_30 = installation.created_at < timezone.now() - timedelta(days=30)
return {
'site_title': get_settings().SITE_TITLE,
# Note: no way to actually set the license key yet, so nagging always happens for now.
'site_title': get_settings().SITE_TITLE + (" (non-production use)" if nag_7 else ""),
'registration_enabled': get_settings().USER_REGISTRATION == CB_ANYBODY,
'app_settings': get_settings(),
# (First version of "should I nag" logic): nag only after considerable time to play with the app, and for "some
# indication" that you're using this in production (the simplest such indication is that you've configured a
# BASE_URL that's not localhost). Subject to change.
'show_free_version_message': nag_30 and '127.0.0.1' not in get_settings().BASE_URL,
}

View File

@@ -0,0 +1,22 @@
# Generated by Django 4.2.16 on 2024-11-11 12:48
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
("phonehome", "0003_outboundmessage"),
]
operations = [
migrations.AddField(
model_name="installation",
name="created_at",
field=models.DateTimeField(
auto_now_add=True, default=django.utils.timezone.now
),
preserve_default=False,
),
]

View File

@@ -5,6 +5,7 @@ from django.db import models
class Installation(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created_at = models.DateTimeField(auto_now_add=True)
class OutboundMessage(models.Model):

File diff suppressed because one or more lines are too long

View File

@@ -43,6 +43,29 @@
{% endif %}
</div>
</div>
{% if show_free_version_message %}
<div class="flex p-4 bg-yellow-100 border-b-2 border-yellow-200">
<div>
This is the free version of Bugsink; usage is limited to a single user for local development only. Using this software in production requires a <a href="https://www.bugsink.com/#pricing" target="_blank" class="font-bold text-slate-800">paid licence</a>.
</div>
</div>
{% endif %}
{% comment %} {# for use when we introduce a notification system #}
<div class="flex p-4 bg-yellow-100 border-b-2 border-yellow-200">
<div>
Foo bar baz
</div>
<div class="ml-auto flex">
{# heroicon's x-circle #}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>
</div>
</div>
{% endcomment %}
<div>
{% block content %}{% endblock %}
</div>