Skip to content

Commit

Permalink
EuroPython 2014 model layout and migrations
Browse files Browse the repository at this point in the history
Stripped down to the bare classes and relations. Code taken from
https://github.com/pysv/djep
  • Loading branch information
MarkusH committed Jan 8, 2015
1 parent 0cd8519 commit 54fddd3
Show file tree
Hide file tree
Showing 35 changed files with 1,886 additions and 54 deletions.
52 changes: 52 additions & 0 deletions accounts/migrations/0001_initial.py
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('schedule', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='BadgeStatus',
fields=[
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
('name', models.CharField(max_length=50, verbose_name='Name')),
('slug', models.SlugField(verbose_name='slug')),
],
options={
'ordering': ('name',),
},
),
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
('short_info', models.TextField(verbose_name='short info', blank=True)),
('avatar', models.ImageField(upload_to='avatars', null=True, verbose_name='avatar', blank=True)),
('num_accompanying_children', models.PositiveIntegerField(null=True, verbose_name='Number of accompanying children', default=0, blank=True)),
('age_accompanying_children', models.CharField(max_length=20, verbose_name='Age of accompanying children', blank=True)),
('twitter', models.CharField(max_length=20, verbose_name='Twitter', blank=True)),
('website', models.URLField(verbose_name='Website', blank=True)),
('organisation', models.TextField(verbose_name='Organisation', blank=True)),
('full_name', models.CharField(max_length=255, verbose_name='Full name', blank=True)),
('display_name', models.CharField(help_text='What name should be displayed to other people?', verbose_name='Display name', max_length=255, blank=True)),
('addressed_as', models.CharField(help_text='How should we call you in mails and dialogs throughout the website?', verbose_name='Address me as', max_length=255, blank=True)),
('accept_pysv_conferences', models.BooleanField(verbose_name='Allow copying to PySV conferences', default=False)),
('accept_ep_conferences', models.BooleanField(verbose_name='Allow copying to EPS conferences', default=False)),
('accept_job_offers', models.BooleanField(verbose_name='Allow sponsors to send job offers', default=False)),
('badge_status', models.ManyToManyField(to='accounts.BadgeStatus', verbose_name='Badge status', related_name='profiles', blank=True)),
('sessions_attending', models.ManyToManyField(to='schedule.Session', verbose_name='Trainings', related_name='attendees', blank=True)),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='profile')),
],
options={
'permissions': (('send_user_mails', 'Allow sending mails to users through the website'), ('export_guidebook', 'Allow export of guidebook data'), ('see_checkin_info', 'Allow seeing check-in information'), ('perform_purchase', 'Allow performing purchases')),
},
),
]
File renamed without changes.
53 changes: 53 additions & 0 deletions accounts/models.py
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _


class BadgeStatus(models.Model):
name = models.CharField(_('Name'), max_length=50)
slug = models.SlugField(_('slug'), max_length=50)

class Meta:
ordering = ('name',)


class Profile(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='profile')
short_info = models.TextField(_('short info'), blank=True)
avatar = models.ImageField(_('avatar'), upload_to='avatars', null=True, blank=True)
num_accompanying_children = models.PositiveIntegerField(_('Number of accompanying children'),
null=True, blank=True, default=0)
age_accompanying_children = models.CharField(_("Age of accompanying children"), blank=True, max_length=20)
twitter = models.CharField(_("Twitter"), blank=True, max_length=20)
website = models.URLField(_("Website"), blank=True)
organisation = models.TextField(_('Organisation'), blank=True)
full_name = models.CharField(_("Full name"), max_length=255, blank=True)
display_name = models.CharField(_("Display name"), max_length=255,
help_text=_('What name should be displayed to other people?'),
blank=True)
addressed_as = models.CharField(_("Address me as"), max_length=255,
help_text=_('How should we call you in mails and dialogs throughout the website?'),
blank=True)
accept_pysv_conferences = models.BooleanField(_('Allow copying to PySV conferences'),
default=False, blank=True)
accept_ep_conferences = models.BooleanField(_('Allow copying to EPS conferences'),
default=False, blank=True)
accept_job_offers = models.BooleanField(_('Allow sponsors to send job offers'),
default=False, blank=True)

badge_status = models.ManyToManyField('accounts.BadgeStatus', blank=True,
verbose_name=_('Badge status'), related_name='profiles')

sessions_attending = models.ManyToManyField('schedule.Session', blank=True,
related_name='attendees', verbose_name=_('Trainings'))

class Meta:
permissions = (
('send_user_mails', _('Allow sending mails to users through the website')),
('export_guidebook', _('Allow export of guidebook data')),
('see_checkin_info', _('Allow seeing check-in information')),
('perform_purchase', _('Allow performing purchases'))
)

0 comments on commit 54fddd3

Please sign in to comment.