Browse Source

make domain display name optional, add get name method, squash migrations

main
Julia Luna 2 years ago
parent
commit
9be0eeac50
Signed by: xenua
GPG Key ID: 6A0C04FA9A7D7582
  1. 6
      scopedsites/migrations/0001_initial_squashed_0002_alter_domain_name.py
  2. 4
      scopedsites/models.py

6
scopedsites/migrations/0001_initial.py → scopedsites/migrations/0001_initial_squashed_0002_alter_domain_name.py

@ -1,11 +1,11 @@
# Generated by Django 4.0.5 on 2022-06-18 17:20 # Generated by Django 4.0.5 on 2022-06-18 21:58
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True replaces = [('scopedsites', '0001_initial'), ('scopedsites', '0002_alter_domain_name')]
dependencies = [ dependencies = [
] ]
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('fqdn', models.CharField(max_length=255, unique=True, verbose_name='FQDN')), ('fqdn', models.CharField(max_length=255, unique=True, verbose_name='FQDN')),
('name', models.CharField(max_length=255, verbose_name='display name')), ('name', models.CharField(blank=True, max_length=255, verbose_name='display name')),
], ],
), ),
] ]

4
scopedsites/models.py

@ -13,8 +13,12 @@ class Domain(models.Model):
name = models.CharField( name = models.CharField(
_('display name'), _('display name'),
max_length=255, max_length=255,
blank=True,
) )
@classmethod @classmethod
def get_from_request(cls, request): def get_from_request(cls, request):
return get_object_or_404(cls, fqdn__iexact=request.META.get('HTTP_HOST', '')) return get_object_or_404(cls, fqdn__iexact=request.META.get('HTTP_HOST', ''))
def get_name(self):
return self.name or self.fqdn

Loading…
Cancel
Save