Skip to content

Commit 9ed627a

Browse files
author
Kátia Nakamura
committed
conference: add conference app
1 parent a2310db commit 9ed627a

10 files changed

Lines changed: 94 additions & 0 deletions

File tree

pyconbalkan/conference/__init__.py

Whitespace-only changes.

pyconbalkan/conference/admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.contrib import admin
2+
3+
from pyconbalkan.conference.models import Conference
4+
5+
6+
class ConferenceAdmin(admin.ModelAdmin):
7+
class Meta:
8+
model = Conference
9+
10+
11+
admin.site.register(Conference, ConferenceAdmin)

pyconbalkan/conference/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.conference.views import ConferenceViewSet
4+
5+
router = routers.DefaultRouter()
6+
router.register(r'conference', ConferenceViewSet)

pyconbalkan/conference/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 ConferenceConfig(AppConfig):
5+
name = 'conference'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.11 on 2018-04-25 18:12
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django_countries.fields
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
initial = True
12+
13+
dependencies = [
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='Conference',
19+
fields=[
20+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('year', models.PositiveIntegerField()),
22+
('city', models.CharField(blank=True, max_length=200, null=True)),
23+
('country', django_countries.fields.CountryField(blank=True, max_length=2, null=True)),
24+
('address', models.TextField(blank=True, null=True)),
25+
('from_date', models.DateField(blank=True, null=True)),
26+
('to_date', models.DateField(blank=True, null=True)),
27+
('max_attendees', models.PositiveIntegerField(blank=True, null=True)),
28+
('type', models.IntegerField(choices=[(0, 'International'), (1, 'National')])),
29+
],
30+
),
31+
]

pyconbalkan/conference/migrations/__init__.py

Whitespace-only changes.

pyconbalkan/conference/models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.db import models
2+
from django_countries.fields import CountryField
3+
4+
5+
class Conference(models.Model):
6+
INTERNATIONAL = 0
7+
NATIONAL = 1
8+
CONF_TYPE = (
9+
(INTERNATIONAL, 'International'),
10+
(NATIONAL, 'National'),
11+
)
12+
13+
year = models.PositiveIntegerField()
14+
city = models.CharField(null=True, blank=True, max_length=200)
15+
country = CountryField(null=True, blank=True)
16+
address = models.TextField(null=True, blank=True)
17+
from_date = models.DateField(null=True, blank=True)
18+
to_date = models.DateField(null=True, blank=True)
19+
max_attendees = models.PositiveIntegerField(null=True, blank=True)
20+
type = models.IntegerField(choices=CONF_TYPE)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from rest_framework import serializers
2+
3+
from pyconbalkan.conference.models import Conference
4+
5+
6+
class ConferenceSerializer(serializers.ModelSerializer):
7+
class Meta:
8+
model = Conference
9+
fields = '__all__'

pyconbalkan/conference/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

pyconbalkan/conference/views.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from rest_framework import viewsets
2+
3+
from pyconbalkan.conference.models import Conference
4+
from pyconbalkan.conference.serializers import ConferenceSerializer
5+
6+
7+
class ConferenceViewSet(viewsets.ModelViewSet):
8+
queryset = Conference.objects.all()
9+
serializer_class = ConferenceSerializer

0 commit comments

Comments
 (0)