Skip to content

Commit

Permalink
feat: subscribers and biography models
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelovicentegc committed Jun 4, 2020
1 parent 265bf9a commit 7dd911e
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 4 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load-plugins=pylint_django
2 changes: 1 addition & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rest_framework import serializers
from frontend.models import Subscribers
from frontend.models.subscribers import Subscribers

class SubscribersSerializer(serializers.ModelSerializer):
class Meta:
Expand Down
2 changes: 1 addition & 1 deletion api/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from frontend.models import Subscribers
from frontend.models.subscribers import Subscribers
from .serializers import SubscribersSerializer
from rest_framework import generics

Expand Down
7 changes: 6 additions & 1 deletion frontend/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from django.contrib import admin
from .models.subscribers import Subscribers
from .models.biography import Biography
from .models.carrousel import Carrousel

# Register your models here.
admin.site.register(Subscribers)
admin.site.register(Biography)
admin.site.register(Carrousel)
45 changes: 45 additions & 0 deletions frontend/migrations/0002_biography_carrousel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.0.7 on 2020-06-04 02:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('frontend', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Biography',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('button_label', models.CharField(max_length=120, verbose_name="Button's label")),
('button_url', models.CharField(max_length=120, verbose_name="Button's link")),
('title', models.CharField(max_length=120, verbose_name='Title')),
('description', models.TextField(max_length=3000, verbose_name='Description')),
('created_at', models.DateTimeField(auto_now_add=True)),
('subtitle', models.CharField(max_length=120, verbose_name='Subtitle')),
('body', models.CharField(max_length=30000, verbose_name='Body')),
],
options={
'verbose_name': 'Biography',
},
),
migrations.CreateModel(
name='Carrousel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('button_label', models.CharField(max_length=120, verbose_name="Button's label")),
('button_url', models.CharField(max_length=120, verbose_name="Button's link")),
('title', models.CharField(max_length=120, verbose_name='Title')),
('description', models.TextField(max_length=3000, verbose_name='Description')),
('created_at', models.DateTimeField(auto_now_add=True)),
('position', models.CharField(choices=[('TOP_CENTER', 'At the top center'), ('TOP_LEFT', 'At the top left'), ('TOP_RIGHT', 'At the top right'), ('BOTTOM_CENTER', 'At the bottom center'), ('BOTTOM_LEFT', 'At the bottom left'), ('BOTTOM_RIGHT', 'At the bottom right'), ('CENTER', 'Centered'), ('CENTER_LEFT', 'Centered left'), ('CENTER_RIGHT', 'Centered right')], default='CENTER', max_length=13, verbose_name='Text position')),
('image', models.ImageField(blank=True, null=True, upload_to='img', verbose_name='Image')),
],
options={
'verbose_name': 'Carrousel item',
},
),
]
Empty file added frontend/models/__init__.py
Empty file.
35 changes: 35 additions & 0 deletions frontend/models/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.db import models


class ButtonBlock(models.Model):
button_label = models.CharField(
max_length=120, verbose_name="Button's label")
button_url = models.CharField(max_length=120, verbose_name="Button's link")

class Meta:
abstract = True


class TextBlockBase(models.Model):
title = models.CharField(max_length=120, verbose_name='Title')
description = models.TextField(max_length=3000, verbose_name='Description')
created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.title

class Meta:
abstract = True


class TextBlock(TextBlockBase):
class Meta:
abstract = True


class EnhancedTextBlock(TextBlockBase, ButtonBlock):
subtitle = models.CharField(max_length=120, verbose_name='Subtitle')
body = models.CharField(max_length=30000, verbose_name='Body')

class Meta:
abstract = True
9 changes: 9 additions & 0 deletions frontend/models/biography.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.db import models
from .base import EnhancedTextBlock

class Biography(EnhancedTextBlock):
def __str__(self):
return self.title

class Meta:
verbose_name = 'Biography'
29 changes: 29 additions & 0 deletions frontend/models/carrousel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.db import models
from .base import TextBlock, ButtonBlock

class Carrousel(TextBlock, ButtonBlock):
class Position(models.TextChoices):
TOP_CENTER = 'TOP_CENTER', 'At the top center'
TOP_LEFT = 'TOP_LEFT', 'At the top left'
TOP_RIGHT = 'TOP_RIGHT', 'At the top right'
BOTTOM_CENTER = 'BOTTOM_CENTER', 'At the bottom center'
BOTTOM_LEFT = 'BOTTOM_LEFT', 'At the bottom left'
BOTTOM_RIGHT = 'BOTTOM_RIGHT', 'At the bottom right'
CENTER = 'CENTER', 'Centered'
CENTER_LEFT = 'CENTER_LEFT', 'Centered left'
CENTER_RIGHT = 'CENTER_RIGHT', 'Centered right'

position = models.CharField(
max_length=13,
choices=Position.choices,
default=Position.CENTER,
verbose_name='Text position'
)
image = models.ImageField(
upload_to='img', null=True, blank=True, verbose_name='Image')

def __str__(self):
return self.title

class Meta:
verbose_name = 'Carrousel item'
3 changes: 2 additions & 1 deletion frontend/models.py → frontend/models/subscribers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.db import models


class Subscribers(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
wpp = models.CharField(max_length=300)
neighborhood = models.CharField(max_length=300)
created_at = models.DateTimeField(auto_now_add=True)
created_at = models.DateTimeField(auto_now_add=True)

0 comments on commit 7dd911e

Please sign in to comment.