2013-11-19 18:32:11 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright (c) 2013 by Pablo Martín <goinnn@gmail.com>
|
|
|
|
#
|
|
|
|
# This software is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This software is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
from django.db import models
|
2016-09-22 20:12:56 +00:00
|
|
|
from django.utils.translation import gettext as _
|
2013-11-19 18:32:11 +00:00
|
|
|
|
|
|
|
from multiselectfield import MultiSelectField
|
|
|
|
|
|
|
|
CATEGORY_CHOICES = (
|
2013-11-26 19:04:41 +00:00
|
|
|
(1, 'Handbooks and manuals by discipline'),
|
2013-11-26 19:34:25 +00:00
|
|
|
(2, 'Business books'),
|
2013-11-26 19:04:41 +00:00
|
|
|
(3, 'Books of literary criticism'),
|
2013-11-19 18:32:11 +00:00
|
|
|
(4, 'Books about literary theory'),
|
2013-11-26 19:04:41 +00:00
|
|
|
(5, 'Books about literature')
|
2013-11-19 18:32:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
TAGS_CHOICES = (
|
2016-09-22 20:12:56 +00:00
|
|
|
('sex', _('Sex')),
|
|
|
|
('work', _('Work')),
|
|
|
|
('happy', _('Happy')),
|
|
|
|
('food', _('Food')),
|
|
|
|
('field', _('Field')),
|
|
|
|
('boring', _('Boring')),
|
|
|
|
('interesting', _('Interesting')),
|
|
|
|
('huge', _('Huge')),
|
|
|
|
('nice', _('Nice')),
|
|
|
|
)
|
|
|
|
|
|
|
|
PROVINCES = (
|
|
|
|
('AB', _("Alberta")),
|
|
|
|
('BC', _("British Columbia")),
|
|
|
|
)
|
|
|
|
|
|
|
|
STATES = (
|
|
|
|
('AK', _("Alaska")),
|
|
|
|
('AL', _("Alabama")),
|
|
|
|
('AZ', _("Arizona")),
|
|
|
|
)
|
|
|
|
|
|
|
|
PROVINCES_AND_STATES = (
|
|
|
|
(_("Canada - Provinces"), PROVINCES),
|
|
|
|
(_("USA - States"), STATES),
|
2013-11-19 18:32:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Book(models.Model):
|
|
|
|
title = models.CharField(max_length=200)
|
2013-11-26 17:56:37 +00:00
|
|
|
categories = MultiSelectField(choices=CATEGORY_CHOICES,
|
2013-11-30 18:25:11 +00:00
|
|
|
max_choices=3,
|
2013-11-30 18:25:58 +00:00
|
|
|
#default='1,5')
|
2013-11-30 18:25:11 +00:00
|
|
|
default=1)
|
2013-11-26 17:56:37 +00:00
|
|
|
tags = MultiSelectField(choices=TAGS_CHOICES,
|
|
|
|
null=True, blank=True)
|
2016-09-22 20:12:56 +00:00
|
|
|
published_in = MultiSelectField(_("Province or State"), max_length=2, choices=PROVINCES_AND_STATES)
|
2013-11-19 18:32:11 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.__str__()
|