# Path: kobra/db_fields.py
# class IdField(models.UUIDField):
#     def __init__(self, *args, **kwargs):
#         kwargs['primary_key'] = kwargs.get('primary_key', True)
#         kwargs['default'] = kwargs.get('default', uuid.uuid4)
#         kwargs['editable'] = kwargs.get('editable', False)
#         kwargs['verbose_name'] = kwargs.get('verbose_name', _('ID'))
#         super(IdField, self).__init__(*args, **kwargs)
# 
# class MoneyField(models.DecimalField):
#     def __init__(self, *args, **kwargs):
#         kwargs['max_digits'] = kwargs.get('max_digits', 12)
#         kwargs['decimal_places'] = 2
#         super(MoneyField, self).__init__(*args, **kwargs)
# 
# class NameField(StripValueMixin, models.CharField):
#     def __init__(self, *args, **kwargs):
#         kwargs['max_length'] = kwargs.get('max_length', 64)
#         kwargs['verbose_name'] = kwargs.get('verbose_name', _('name'))
#         super(NameField, self).__init__(*args, **kwargs)


import logging
import sesam
from django.conf import settings
from django.contrib.auth.models import (
    AbstractBaseUser,
    BaseUserManager,
    PermissionsMixin
)
from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from .db_fields import IdField, MoneyField, NameField
        try:
            student = Student.objects.get(**student_kwargs)
        except Student.DoesNotExist:
            # Just instantiate, don't save.
            student = Student(**student_kwargs)

    student.email = sesam_student.email
    student.liu_id = sesam_student.liu_id
    student.liu_lin = sesam_student.liu_lin
    student.full_name = sesam_student.full_name
    student.first_name = sesam_student.first_name
    student.last_name = sesam_student.last_name
    student.union = Union.objects.get_or_create(
        name=sesam_student.main_union)[0] if sesam_student.main_union else None
    # The student_union field in Sesam is not a good indicator of section
    # membership and is therefore deprecated.
    student.section = None

    return student


class Discount(models.Model):
    id = IdField()

    ticket_type = models.ForeignKey(
        'TicketType',
        related_name='discounts')
    union = models.ForeignKey(
        'Union',
        related_name='discounts')

# Path: kobra/db_fields.py
# class IdField(models.UUIDField):
#     def __init__(self, *args, **kwargs):
#         kwargs['primary_key'] = kwargs.get('primary_key', True)
#         kwargs['default'] = kwargs.get('default', uuid.uuid4)
#         kwargs['editable'] = kwargs.get('editable', False)
#         kwargs['verbose_name'] = kwargs.get('verbose_name', _('ID'))
#         super(IdField, self).__init__(*args, **kwargs)
# 
# class MoneyField(models.DecimalField):
#     def __init__(self, *args, **kwargs):
#         kwargs['max_digits'] = kwargs.get('max_digits', 12)
#         kwargs['decimal_places'] = 2
#         super(MoneyField, self).__init__(*args, **kwargs)
# 
# class NameField(StripValueMixin, models.CharField):
#     def __init__(self, *args, **kwargs):
#         kwargs['max_length'] = kwargs.get('max_length', 64)
#         kwargs['verbose_name'] = kwargs.get('verbose_name', _('name'))
#         super(NameField, self).__init__(*args, **kwargs)


# Path: kobra/models.py
import logging
import sesam
from django.conf import settings
from django.contrib.auth.models import (
    AbstractBaseUser,
    BaseUserManager,
    PermissionsMixin
)
from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from .db_fields import IdField, MoneyField, NameField

        try:
            student = Student.objects.get(**student_kwargs)
        except Student.DoesNotExist:
            # Just instantiate, don't save.
            student = Student(**student_kwargs)

    student.email = sesam_student.email
    student.liu_id = sesam_student.liu_id
    student.liu_lin = sesam_student.liu_lin
    student.full_name = sesam_student.full_name
    student.first_name = sesam_student.first_name
    student.last_name = sesam_student.last_name
    student.union = Union.objects.get_or_create(
        name=sesam_student.main_union)[0] if sesam_student.main_union else None
    # The student_union field in Sesam is not a good indicator of section
    # membership and is therefore deprecated.
    student.section = None

    return student


class Discount(models.Model):
    id = IdField()

    ticket_type = models.ForeignKey(
        'TicketType',
        related_name='discounts')
    union = models.ForeignKey(
        'Union',
        related_name='discounts')

    amount = MoneyField(