diff --git a/apps/gnous_eu/admin.py b/apps/gnous_eu/admin.py index b86da0c..829320e 100644 --- a/apps/gnous_eu/admin.py +++ b/apps/gnous_eu/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from apps.gnous_eu.models import Service +from apps.gnous_eu.models import Service, Partner class ServicesAdmin(admin.ModelAdmin): @@ -22,3 +22,21 @@ class ServicesAdmin(admin.ModelAdmin): admin.site.register(Service, ServicesAdmin) + + +class PartnersAdmin(admin.ModelAdmin): + list_display = ( + "id", + "name", + "domain_tag", + "image_tag", + "hidden", + ) + fieldsets = [ + ("Global", {"fields": ["name", "domain", "photo"]}), + ("Descriptions", {"fields": ["description", "description_en"]}), + ("Misc", {"fields": ["hidden"]}), + ] + + +admin.site.register(Partner, PartnersAdmin) diff --git a/apps/gnous_eu/migrations/0003_partner.py b/apps/gnous_eu/migrations/0003_partner.py new file mode 100644 index 0000000..dd0e64b --- /dev/null +++ b/apps/gnous_eu/migrations/0003_partner.py @@ -0,0 +1,25 @@ +# Generated by Django 3.0.2 on 2020-06-18 23:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gnous_eu', '0002_service_description_en'), + ] + + operations = [ + migrations.CreateModel( + name='Partner', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=150)), + ('description', models.TextField()), + ('description_en', models.TextField(null=True)), + ('photo', models.ImageField(upload_to='partner')), + ('domain', models.CharField(max_length=150)), + ('hidden', models.BooleanField(default=False)), + ], + ), + ] diff --git a/apps/gnous_eu/models.py b/apps/gnous_eu/models.py index 923f2ac..c5f514a 100644 --- a/apps/gnous_eu/models.py +++ b/apps/gnous_eu/models.py @@ -42,3 +42,26 @@ class Service(models.Model): f'"{settings.MEDIA_URL + self.photo.name}"' f' width="50" height="50">' ) + + +class Partner(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=150) + description = models.TextField() + description_en = models.TextField(null=True) + photo = models.ImageField(upload_to="partner") + + domain = models.CharField(max_length=150) + hidden = models.BooleanField(default=False) + + def domain_tag(self): + return mark_safe( + f'{self.domain}' + ) + + def image_tag(self): + return mark_safe( + f"' + )