Skip to content

Commit a07de70

Browse files
author
Kátia Nakamura
committed
organizers: add organizers app
1 parent 64be8c2 commit a07de70

18 files changed

Lines changed: 398 additions & 10 deletions

File tree

pyconbalkan/core/models.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
from django.db import models
22

33

4-
class SingleActiveModel(models.Model):
4+
class Person(models.Model):
5+
full_name = models.CharField(max_length=256, null=True)
6+
name = models.CharField(max_length=256, blank=True, null=True)
7+
8+
date_of_birth = models.DateField(blank=True, null=True)
9+
job = models.CharField(max_length=100, blank=True, null=True)
10+
company = models.CharField(max_length=100, blank=True, null=True)
11+
personal_website = models.URLField(blank=True, null=True)
12+
linkedin = models.URLField(blank=True, null=True)
13+
facebook = models.URLField(blank=True, null=True)
14+
twitter = models.URLField(blank=True, null=True)
15+
16+
class Meta:
17+
abstract = True
18+
19+
def __str__(self):
20+
return self.name
21+
22+
class ActiveModel(models.Model):
523
active = models.BooleanField(default=False)
624

725
class Meta:
826
abstract = True
927

28+
29+
class SingleActiveModel(ActiveModel):
30+
31+
class Meta:
32+
abstract = True
33+
1034
def save(self, *args, **kwargs):
1135
if self.active:
1236
# select all other active items

pyconbalkan/core/views.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from django.shortcuts import render
22

33
from pyconbalkan.conference.models import Conference, CountDown
4-
from pyconbalkan.speaker.models import Speaker, SpeakerPhoto
4+
from pyconbalkan.organizers.models import Volunteer
5+
from pyconbalkan.speaker.models import Speaker
56

67

78
def home(request):
@@ -16,3 +17,13 @@ def home(request):
1617
return render(request, 'home.html', context)
1718

1819

20+
def organizers(request):
21+
volunteers = Volunteer.objects.filter(type=Volunteer.VOLUNTEER, active=True)
22+
organizers = Volunteer.objects.filter(type=Volunteer.ORGANIZER, active=True)
23+
conference = Conference.objects.filter(active=True)
24+
context = {
25+
'volunteers': volunteers,
26+
'organizers': organizers,
27+
'conference': conference.first() if conference else None,
28+
}
29+
return render(request, 'organizers.html', context)

pyconbalkan/organizers/__init__.py

Whitespace-only changes.

pyconbalkan/organizers/admin.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.contrib import admin
2+
3+
from pyconbalkan.organizers.models import Volunteer, VolunteerPhoto
4+
5+
6+
class VolunteerImageInline(admin.TabularInline):
7+
model = VolunteerPhoto
8+
9+
class VolunteerAdmin(admin.ModelAdmin):
10+
inlines = [VolunteerImageInline]
11+
12+
13+
admin.site.register(Volunteer, VolunteerAdmin)

pyconbalkan/organizers/api_urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from rest_framework import routers
2+
3+
from pyconbalkan.organizers.views import VolunteerViewSet
4+
5+
router = routers.DefaultRouter()
6+
router.register(r'organizers', VolunteerViewSet)

pyconbalkan/organizers/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class OrganizationConfig(AppConfig):
5+
name = 'organizers'
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.11 on 2018-05-06 18:14
3+
from __future__ import unicode_literals
4+
5+
from django.conf import settings
6+
from django.db import migrations, models
7+
import django.db.models.deletion
8+
9+
10+
class Migration(migrations.Migration):
11+
12+
initial = True
13+
14+
dependencies = [
15+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16+
]
17+
18+
operations = [
19+
migrations.CreateModel(
20+
name='Volunteer',
21+
fields=[
22+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23+
('full_name', models.CharField(max_length=256, null=True)),
24+
('name', models.CharField(blank=True, max_length=256, null=True)),
25+
('email', models.EmailField(blank=True, max_length=254, null=True)),
26+
('date_of_birth', models.DateField(blank=True, null=True)),
27+
('job', models.CharField(blank=True, max_length=100, null=True)),
28+
('company', models.CharField(blank=True, max_length=100, null=True)),
29+
('personal_website', models.URLField(blank=True, null=True)),
30+
('linkedin', models.URLField(blank=True, null=True)),
31+
('facebook', models.URLField(blank=True, null=True)),
32+
('twitter', models.URLField(blank=True, null=True)),
33+
('active', models.BooleanField(default=False)),
34+
('type', models.IntegerField(choices=[(0, 'Organizer'), (1, 'Volunteer')], default=1)),
35+
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='volunteer', to=settings.AUTH_USER_MODEL)),
36+
],
37+
options={
38+
'abstract': False,
39+
},
40+
),
41+
migrations.CreateModel(
42+
name='VolunteerPhoto',
43+
fields=[
44+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
45+
('profile_picture', models.ImageField(upload_to='static/img')),
46+
('volunteer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='organizers.Volunteer')),
47+
],
48+
),
49+
]

pyconbalkan/organizers/migrations/__init__.py

Whitespace-only changes.

pyconbalkan/organizers/models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.contrib.auth.models import User
2+
from django.db import models
3+
4+
from pyconbalkan.core.models import Person, ActiveModel
5+
6+
7+
class Volunteer(ActiveModel, Person):
8+
ORGANIZER = 0
9+
VOLUNTEER = 1
10+
VOLUNTEER_TYPE = (
11+
(ORGANIZER, 'Organizer'),
12+
(VOLUNTEER, 'Volunteer'),
13+
)
14+
15+
user = models.ForeignKey(User, blank=True, null=True, related_name='volunteer')
16+
type = models.IntegerField(choices=VOLUNTEER_TYPE, default=VOLUNTEER)
17+
18+
class VolunteerPhoto(models.Model):
19+
volunteer = models.ForeignKey(Volunteer, related_name='images')
20+
profile_picture = models.ImageField(upload_to="static/img")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from rest_framework import serializers
2+
3+
from pyconbalkan.conference.models import Conference
4+
from pyconbalkan.organizers.models import Volunteer
5+
6+
7+
class VolunteerSerializer(serializers.ModelSerializer):
8+
class Meta:
9+
model = Volunteer
10+
fields = '__all__'

0 commit comments

Comments
 (0)