Skip to content

Commit

Permalink
Merge pull request #1131 from pycontw/feat/1119
Browse files Browse the repository at this point in the history
Refactoring model options from models.py (issue#1119)
  • Loading branch information
josix authored Mar 13, 2023
2 parents 9d82a22 + 3be480d commit 75b4d2f
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 271 deletions.
70 changes: 70 additions & 0 deletions src/core/choices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from django.utils.translation import gettext_lazy as _

CATEGORY_CHOICES = (
('APPL', _('Application')),
('PRAC', _('Best Practices & Patterns')),
('COM', _('Community')),
('DB', _('Databases')),
('DATA', _('Data Analysis')),
('EDU', _('Education')),
('EMBED', _('Embedded Systems')),
('FIN', _('FinTech')),
('IOT', _('Internet of Things')),
('GAME', _('Gaming')),
('GRAPH', _('Graphics')),
('ML', _('Machine Learning')),
('NLP', _('Natural Language Processing')),
('CORE', _('Python Core (language, stdlib, etc.)')),
('TOOL', _('Project Tooling')),
('SCI', _('Science')),
('SEC', _('Security')),
('ADMIN', _('Systems Administration')),
('TEST', _('Testing')),
('WEB', _('Web Frameworks')),
('OTHER', _('Other')),
)

LANGUAGE_CHOICES = (
('ENEN', _('English talk')),
('ZHEN', _('Chinese talk w. English slides')),
('ZHZH', _('Chinese talk w. Chinese slides')),
('TAI', _('Taiwanese Hokkien')),
)

PYTHON_LVL_CHOICES = (
('NOVICE', _('Novice')),
('INTERMEDIATE', _('Intermediate')),
('EXPERIENCED', _('Experienced')),
)

PREFER_TIME_CHOICES = (
('DAY_ONE_MORNING', _('Day 1, September 2nd, 2023 Morning')),
('DAY_ONE_AFTERNOON', _('Day 1, September 2nd, 2023 Afternoon')),
('DAY_TWO_MORNING', _('Day 2, September 3rd, 2023 Morning')),
('DAY_TWO_AFTERNOON', _('Day 2, September 3rd, 2023 Afternoon')),
)

RECORDING_POLICY_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)

LIVING_IN_TAIWAN_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)

LIVE_STREAM_POLICY_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)

REFERRING_POLICY_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)

ATTEND_IN_PERSON = (
(True, _('Yes')),
(False, _('No')),
)
80 changes: 15 additions & 65 deletions src/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from .choices import (
CATEGORY_CHOICES,
LANGUAGE_CHOICES,
PYTHON_LVL_CHOICES,
PREFER_TIME_CHOICES,
RECORDING_POLICY_CHOICES,
LIVING_IN_TAIWAN_CHOICES,
LIVE_STREAM_POLICY_CHOICES,
REFERRING_POLICY_CHOICES,
ATTEND_IN_PERSON,
)
from .validators import EAWMaxLengthValidator


Expand Down Expand Up @@ -84,41 +95,12 @@ class EventInfo(models.Model):
max_length=140,
)

CATEGORY_CHOICES = (
('APPL', _('Application')),
('PRAC', _('Best Practices & Patterns')),
('COM', _('Community')),
('DB', _('Databases')),
('DATA', _('Data Analysis')),
('EDU', _('Education')),
('EMBED', _('Embedded Systems')),
('FIN', _('FinTech')),
('IOT', _('Internet of Things')),
('GAME', _('Gaming')),
('GRAPH', _('Graphics')),
('ML', _('Machine Learning')),
('NLP', _('Natural Language Processing')),
('CORE', _('Python Core (language, stdlib, etc.)')),
('TOOL', _('Project Tooling')),
('SCI', _('Science')),
('SEC', _('Security')),
('ADMIN', _('Systems Administration')),
('TEST', _('Testing')),
('WEB', _('Web Frameworks')),
('OTHER', _('Other')),
)
category = models.CharField(
verbose_name=_('category'),
max_length=5,
choices=CATEGORY_CHOICES,
)

LANGUAGE_CHOICES = (
('ENEN', _('English talk')),
('ZHEN', _('Chinese talk w. English slides')),
('ZHZH', _('Chinese talk w. Chinese slides')),
('TAI', _('Taiwanese Hokkien')),
)
language = models.CharField(
verbose_name=_('language'),
max_length=5,
Expand All @@ -130,11 +112,6 @@ class EventInfo(models.Model):
max_length=1000,
)

PYTHON_LVL_CHOICES = (
('NOVICE', _('Novice')),
('INTERMEDIATE', _('Intermediate')),
('EXPERIENCED', _('Experienced')),
)
python_level = models.CharField(
verbose_name=_('Python level'),
max_length=12,
Expand All @@ -146,30 +123,18 @@ class EventInfo(models.Model):
blank=True,
)

RECORDING_POLICY_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)
recording_policy = models.BooleanField(
verbose_name=_('recording policy'),
default=True,
choices=RECORDING_POLICY_CHOICES,
)

LIVE_STREAM_POLICY_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)
live_stream_policy = models.BooleanField(
verbose_name=_('live stream policy'),
default=True,
choices=LIVE_STREAM_POLICY_CHOICES,
)

REFERRING_POLICY_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)
referring_policy = models.BooleanField(
verbose_name=_('referring policy'),
default=False,
Expand Down Expand Up @@ -205,37 +170,22 @@ class EventInfo(models.Model):
auto_now=True,
)

PERFER_TIME_CHOICES = (
('DAY_ONE_MORNING', _('Day 1, September 2nd, 2023 Morning')),
('DAY_ONE_AFTERNOON', _('Day 1, September 2nd, 2023 Afternoon')),
('DAY_TWO_MORNING', _('Day 2, September 3rd, 2023 Morning')),
('DAY_TWO_AFTERNOON', _('Day 2, September 3rd, 2023 Afternoon')),
)
prefer_time = models.CharField(
verbose_name=_('prefer event time'),
max_length=32,
choices=PERFER_TIME_CHOICES,
choices=PREFER_TIME_CHOICES,
)

LIVING_IN_TAIWAN_CHOICES = (
(True, _('Yes')),
(False, _('No'))
)
living_in_taiwan = models.BooleanField(
verbose_name=_('living in Taiwan'),
default=False,
choices=REFERRING_POLICY_CHOICES,
)

WILLING_TO_ATTEND_IN_PERSON = (
(True, _('Yes')),
(False, _('No')),
choices=LIVING_IN_TAIWAN_CHOICES,
)

willing_to_attend_in_person = models.BooleanField(
attend_in_person = models.BooleanField(
verbose_name=_("attending PyCon TW in person"),
default=True,
choices=WILLING_TO_ATTEND_IN_PERSON,
choices=ATTEND_IN_PERSON,
)

class Meta:
Expand Down
18 changes: 18 additions & 0 deletions src/events/migrations/0049_rename_willing_to.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.7 on 2023-02-26 14:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('events', '0048_add_willing_to_attend_in_person'),
]

operations = [
migrations.RenameField(
model_name='sponsoredevent',
old_name='willing_to_attend_in_person',
new_name='attend_in_person',
),
]
Loading

0 comments on commit 75b4d2f

Please sign in to comment.