Adding tickets app, removing signup from camps app, setting dev db to postgres.
This commit is contained in:
parent
39ad0b82fc
commit
2923372488
|
@ -23,6 +23,7 @@ INSTALLED_APPS = [
|
|||
|
||||
'profiles',
|
||||
'camps',
|
||||
'tickets',
|
||||
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
|
|
|
@ -7,8 +7,12 @@ DEBUG = True
|
|||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': local_dir('db.sqlite3'),
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'bornhack_dev',
|
||||
'USER': 'bornhack',
|
||||
'PASSWORD': 'bornhack',
|
||||
'HOST': 'localhost',
|
||||
'PORT': 5432,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Camp, Day, Expense, Signup
|
||||
from .models import Camp, Day, Expense
|
||||
|
||||
|
||||
@admin.register(Expense)
|
||||
|
@ -12,15 +12,6 @@ class ExpenseInlineAdmin(admin.TabularInline):
|
|||
model = Expense
|
||||
|
||||
|
||||
@admin.register(Signup)
|
||||
class SignupAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
class SignupInlineAdmin(admin.TabularInline):
|
||||
model = Signup
|
||||
|
||||
|
||||
@admin.register(Day)
|
||||
class DayAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
@ -35,5 +26,4 @@ class CampAdmin(admin.ModelAdmin):
|
|||
inlines = [
|
||||
DayInlineAdmin,
|
||||
ExpenseInlineAdmin,
|
||||
SignupInlineAdmin
|
||||
]
|
||||
|
|
26
camps/migrations/0003_auto_20160422_2019.py
Normal file
26
camps/migrations/0003_auto_20160422_2019.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-04-22 20:19
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('camps', '0002_auto_20160117_1718'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='signup',
|
||||
name='camp',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='signup',
|
||||
name='user',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Signup',
|
||||
),
|
||||
]
|
|
@ -118,35 +118,3 @@ class Expense(CreatedUpdatedModel, UUIDModel):
|
|||
self.get_currency_display(),
|
||||
self.camp,
|
||||
)
|
||||
|
||||
|
||||
class Signup(CreatedUpdatedModel, UUIDModel):
|
||||
class Meta:
|
||||
verbose_name = _('Signup')
|
||||
verbose_name_plural = _('Signups')
|
||||
|
||||
camp = models.ForeignKey(
|
||||
'camps.Camp',
|
||||
verbose_name=_('Camp'),
|
||||
help_text=_('The camp that has been signed up for.'),
|
||||
)
|
||||
|
||||
user = models.ForeignKey(
|
||||
'auth.User',
|
||||
verbose_name=_('User'),
|
||||
help_text=_('The user that has signed up.'),
|
||||
)
|
||||
|
||||
cost = models.DecimalField(
|
||||
verbose_name=_('Cost'),
|
||||
help_text=_('What the user should/is willing to pay for this signup.'),
|
||||
max_digits=7,
|
||||
decimal_places=2,
|
||||
default=1500.0
|
||||
)
|
||||
|
||||
paid = models.BooleanField(
|
||||
verbose_name=_('Paid?'),
|
||||
help_text=_('Whether the user has paid.'),
|
||||
default=False,
|
||||
)
|
||||
|
|
0
tickets/__init__.py
Normal file
0
tickets/__init__.py
Normal file
29
tickets/admin.py
Normal file
29
tickets/admin.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Ticket, TicketType
|
||||
|
||||
|
||||
@admin.register(Ticket)
|
||||
class TicketAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'user',
|
||||
'ticket_type',
|
||||
'camp',
|
||||
'paid',
|
||||
]
|
||||
|
||||
list_filter = [
|
||||
'paid',
|
||||
'ticket_type',
|
||||
'camp',
|
||||
]
|
||||
|
||||
|
||||
@admin.register(TicketType)
|
||||
class TicketTypeAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
'name',
|
||||
'price',
|
||||
'available_in',
|
||||
'camp',
|
||||
]
|
5
tickets/apps.py
Normal file
5
tickets/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TicketsConfig(AppConfig):
|
||||
name = 'tickets'
|
62
tickets/migrations/0001_initial.py
Normal file
62
tickets/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-04-22 20:19
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.postgres.fields.ranges
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('camps', '0003_auto_20160422_2019'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Ticket',
|
||||
fields=[
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('paid', models.BooleanField(default=False, help_text='Whether the user has paid.', verbose_name='Paid?')),
|
||||
('camp', models.ForeignKey(help_text='The camp this ticket is for.', on_delete=django.db.models.deletion.CASCADE, to='camps.Camp', verbose_name='Camp')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Tickets',
|
||||
'verbose_name': 'Ticket',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='TicketType',
|
||||
fields=[
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('updated', models.DateTimeField(auto_now=True)),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('price', models.IntegerField(help_text='Price of the ticket (in DKK).')),
|
||||
('available_in', django.contrib.postgres.fields.ranges.DateTimeRangeField(help_text='Which period is this ticket available for purchase?')),
|
||||
('camp', models.ForeignKey(help_text='The camp this ticket type is for.', on_delete=django.db.models.deletion.CASCADE, to='camps.Camp', verbose_name='Camp')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Ticket Types',
|
||||
'verbose_name': 'Ticket Type',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ticket',
|
||||
name='ticket_type',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tickets.TicketType'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ticket',
|
||||
name='user',
|
||||
field=models.ForeignKey(help_text='The user this ticket belongs to.', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User'),
|
||||
),
|
||||
]
|
0
tickets/migrations/__init__.py
Normal file
0
tickets/migrations/__init__.py
Normal file
60
tickets/models.py
Normal file
60
tickets/models.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
from django.db import models
|
||||
from django.contrib.postgres.fields import DateTimeRangeField
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from bornhack.utils import CreatedUpdatedModel, UUIDModel
|
||||
|
||||
|
||||
class Ticket(CreatedUpdatedModel, UUIDModel):
|
||||
class Meta:
|
||||
verbose_name = _('Ticket')
|
||||
verbose_name_plural = _('Tickets')
|
||||
|
||||
camp = models.ForeignKey(
|
||||
'camps.Camp',
|
||||
verbose_name=_('Camp'),
|
||||
help_text=_('The camp this ticket is for.'),
|
||||
)
|
||||
|
||||
user = models.ForeignKey(
|
||||
'auth.User',
|
||||
verbose_name=_('User'),
|
||||
help_text=_('The user this ticket belongs to.'),
|
||||
)
|
||||
|
||||
paid = models.BooleanField(
|
||||
verbose_name=_('Paid?'),
|
||||
help_text=_('Whether the user has paid.'),
|
||||
default=False,
|
||||
)
|
||||
|
||||
ticket_type = models.ForeignKey(
|
||||
'tickets.TicketType',
|
||||
verbose_name=_('Ticket type'),
|
||||
help_text=_('The type of the ticket.'),
|
||||
)
|
||||
|
||||
|
||||
class TicketType(CreatedUpdatedModel, UUIDModel):
|
||||
class Meta:
|
||||
verbose_name = _('Ticket Type')
|
||||
verbose_name_plural = _('Ticket Types')
|
||||
|
||||
name = models.CharField(max_length=150)
|
||||
|
||||
camp = models.ForeignKey(
|
||||
'camps.Camp',
|
||||
verbose_name=_('Camp'),
|
||||
help_text=_('The camp this ticket type is for.'),
|
||||
)
|
||||
|
||||
price = models.IntegerField(
|
||||
help_text=_('Price of the ticket (in DKK).')
|
||||
)
|
||||
|
||||
available_in = DateTimeRangeField(
|
||||
help_text=_('Which period is this ticket available for purchase?')
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
3
tickets/tests.py
Normal file
3
tickets/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
tickets/views.py
Normal file
3
tickets/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in a new issue