diff --git a/pyconbalkan/settings.py b/pyconbalkan/settings.py index 0deec9c3..4ad1961c 100644 --- a/pyconbalkan/settings.py +++ b/pyconbalkan/settings.py @@ -50,6 +50,7 @@ 'pyconbalkan.cfp', 'pyconbalkan.contact', 'pyconbalkan.news', + 'pyconbalkan.sponsoring', 'pyconbalkan.coc', # others 'rest_framework', diff --git a/pyconbalkan/sponsoring/__init__.py b/pyconbalkan/sponsoring/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pyconbalkan/sponsoring/admin.py b/pyconbalkan/sponsoring/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/pyconbalkan/sponsoring/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/pyconbalkan/sponsoring/apps.py b/pyconbalkan/sponsoring/apps.py new file mode 100644 index 00000000..65d58466 --- /dev/null +++ b/pyconbalkan/sponsoring/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class SponsoringConfig(AppConfig): + name = 'sponsoring' diff --git a/pyconbalkan/sponsoring/migrations/0001_initial.py b/pyconbalkan/sponsoring/migrations/0001_initial.py new file mode 100644 index 00000000..7d515d19 --- /dev/null +++ b/pyconbalkan/sponsoring/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 2.0.5 on 2018-06-25 10:56 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Sponsoring', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('organization', models.CharField(blank=True, max_length=100, null=True)), + ('name', models.CharField(max_length=256)), + ('phone', models.CharField(blank=True, max_length=17, validators=[django.core.validators.RegexValidator(message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.", regex='^\\+?1?\\d{9,15}$')])), + ('email', models.EmailField(max_length=254)), + ], + ), + ] diff --git a/pyconbalkan/sponsoring/migrations/__init__.py b/pyconbalkan/sponsoring/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pyconbalkan/sponsoring/models.py b/pyconbalkan/sponsoring/models.py new file mode 100644 index 00000000..0f911298 --- /dev/null +++ b/pyconbalkan/sponsoring/models.py @@ -0,0 +1,63 @@ +from django.db import models +from django import forms +from django.forms import ModelForm +from django.core.validators import RegexValidator +from django.forms.widgets import RadioSelect + + +class Sponsoring(models.Model): + organization = models.CharField(max_length=100, null=True, blank=True) + name = models.CharField(max_length=256) + phone_regex = RegexValidator( + regex=r'^\+?1?\d{9,15}$', + message= + "Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed." + ) + phone = models.CharField( + validators=[phone_regex], max_length=17, blank=True) + email = models.EmailField() + + def __str__(self): + sponsoring_str = '{} | {} | {}'.format(self.name, self.phone, + self.email) + if self.organization: + return '{} | {}'.format(sponsoring_str, self.organization) + return sponsoring_str + + +class SponsoringForm(ModelForm): + organization = forms.CharField( + widget=forms.TextInput(attrs={'class': 'form-control'}), + max_length=100, + required=False, + label='Sponsor Organization') + organization_type = forms.ChoiceField(choices=((0, 'For - profit corporation'), (1, 'Foundation / Non profit')), label='Type of organization', widget=RadioSelect()) + name = forms.CharField( + widget=forms.TextInput(attrs={'class': 'form-control'}), + max_length=256, + error_messages={'required': 'Please, enter your name.'}, + label='Name and Surname') + phone = forms.CharField( + widget=forms.TextInput(attrs={'class': 'form-control'}), + max_length=17, + error_messages={ + 'required': 'Please enter your phone number.', + 'invalid': 'Please enter a valid phone number.' + }, + label='Phone number') + email = forms.EmailField( + widget=forms.TextInput(attrs={'class': 'form-control'}), + error_messages={ + 'required': 'Please, enter a valid email address.', + 'invalid': 'Please enter a valid email address.' + }, + label='e-mail') + CHOICES = (('platinum', '5000'), + ('gold', '2500'), + ('silver', '1000'), + ('bronze', '500'),) + level = forms.ChoiceField(choices=CHOICES, label='Level of sponsorship', widget=RadioSelect()) + + class Meta: + model = Sponsoring + fields = '__all__' diff --git a/pyconbalkan/sponsoring/serializers.py b/pyconbalkan/sponsoring/serializers.py new file mode 100644 index 00000000..c4299259 --- /dev/null +++ b/pyconbalkan/sponsoring/serializers.py @@ -0,0 +1,8 @@ +from rest_framework import serializers +from pyconbalkan.sponsoring.models import Sponsoring + + +class SponsoringSerializer(serializers.ModelSerializer): + class Meta: + model = Sponsoring + fields = '__all__' diff --git a/pyconbalkan/sponsoring/templates/sponsoring.html b/pyconbalkan/sponsoring/templates/sponsoring.html new file mode 100644 index 00000000..c24746d4 --- /dev/null +++ b/pyconbalkan/sponsoring/templates/sponsoring.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% block main_content %} + +{# Sponsoring #} + +