2010-11-29 13:02:19 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from tagging.fields import TagField
|
2011-01-04 06:27:10 +00:00
|
|
|
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
|
|
|
from app.models import ItfModel
|
2010-11-29 13:02:19 +00:00
|
|
|
|
|
|
|
GENRES = (
|
|
|
|
('Fiction', 'Fiction'),
|
|
|
|
('Comedy', 'Comedy'),
|
|
|
|
)
|
|
|
|
|
2011-10-13 14:40:45 +00:00
|
|
|
LICENSE_TYPE_CHOICES = (
|
|
|
|
('adapt', 'Adaptation License'),
|
|
|
|
('perform', 'Performance License'),
|
|
|
|
)
|
|
|
|
|
2010-11-29 13:02:19 +00:00
|
|
|
LANGUAGE_CHOICES = (
|
|
|
|
('en', 'English'),
|
|
|
|
('hi', 'Hindi'),
|
|
|
|
('ma', 'Marathi'),
|
|
|
|
('be', 'Bengali'),
|
|
|
|
)
|
|
|
|
|
2011-01-04 06:27:10 +00:00
|
|
|
class Script(ItfModel):
|
2010-11-29 13:02:19 +00:00
|
|
|
user = models.ForeignKey(User)
|
|
|
|
title = models.CharField(max_length=255)
|
|
|
|
synopsis = models.TextField(blank=True)
|
2011-10-16 16:26:41 +00:00
|
|
|
no_characters = models.IntegerField(blank=True, null=True, help_text="Approximate number of characters")
|
|
|
|
no_of_women = models.IntegerField(blank=True, null=True, help_text="How many characters are women?")
|
2010-11-29 13:02:19 +00:00
|
|
|
tags = TagField(blank=True)
|
|
|
|
production_notes = models.TextField(blank=True, help_text="Additional production notes")
|
|
|
|
language = models.CharField(max_length=32, choices=LANGUAGE_CHOICES)
|
2011-10-16 16:26:41 +00:00
|
|
|
approx_duration = models.IntegerField(blank=True, null=True, help_text="Approximate time, in minutes")
|
2010-11-29 13:02:19 +00:00
|
|
|
is_partial = models.BooleanField(default=False, help_text="Check this if you are uploading only a partial script")
|
|
|
|
author = models.CharField(max_length=255)
|
|
|
|
contact = models.EmailField()
|
|
|
|
script = models.FileField(null=True, upload_to='upload/scripts/')
|
2011-10-13 14:40:45 +00:00
|
|
|
license_adapt = models.ForeignKey("License", related_name="adaptation_license", help_text="License for adaptation rights")
|
|
|
|
license_perform = models.ForeignKey("License", related_name="performance_license", help_text="License for performance rights")
|
2011-01-04 06:27:10 +00:00
|
|
|
fts_fields = ['title', 'synopsis', 'author']
|
|
|
|
fk_fields = ['license_adapt', 'license_perform']
|
|
|
|
|
2011-10-24 02:20:12 +00:00
|
|
|
add_form = 'ScriptForm'
|
|
|
|
|
2011-01-04 06:27:10 +00:00
|
|
|
#Meta
|
|
|
|
added = models.DateTimeField(auto_now_add=True)
|
|
|
|
modified = models.DateTimeField(auto_now=True)
|
2010-11-29 13:02:19 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
2011-10-24 02:03:12 +00:00
|
|
|
def list_dict(self):
|
|
|
|
return {
|
|
|
|
'id': self.id,
|
|
|
|
'title': self.title,
|
|
|
|
}
|
|
|
|
|
|
|
|
def info_dict(self):
|
|
|
|
return {
|
|
|
|
'title': self.title,
|
|
|
|
'synopsis': self.synopsis,
|
|
|
|
'no_characters': self.no_characters,
|
|
|
|
'no_of_women': self.no_of_women,
|
|
|
|
'production_notes': self.production_notes,
|
|
|
|
'language': self.language,
|
|
|
|
'approx_duration': self.approx_duration,
|
|
|
|
'is_partial': self.is_partial,
|
|
|
|
'author': self.author,
|
|
|
|
'contact': self.contact,
|
|
|
|
'script_file': self.script.url,
|
|
|
|
'license_adapt': self.license_adapt,
|
|
|
|
'license_perform': self.license_perform
|
|
|
|
}
|
|
|
|
|
2011-01-04 06:27:10 +00:00
|
|
|
'''
|
|
|
|
@classmethod
|
|
|
|
def get_list(kls, data):
|
|
|
|
options = {
|
|
|
|
'page_no': 1,
|
|
|
|
'list_size': 8
|
|
|
|
}
|
|
|
|
options.update(data)
|
|
|
|
l = []
|
|
|
|
page_no = options['page_no']
|
|
|
|
list_size = options['list_size']
|
|
|
|
qset = kls.objects.all()
|
|
|
|
|
|
|
|
paginator = Paginator(qset, list_size)
|
|
|
|
try:
|
|
|
|
results = paginator.page(page_no)
|
|
|
|
except (EmptyPage, InvalidPage):
|
|
|
|
results = paginator.page(paginator.num_pages)
|
|
|
|
for r in results.object_list:
|
|
|
|
l.append({
|
|
|
|
'id': r.id,
|
|
|
|
'title': r.title
|
|
|
|
})
|
|
|
|
return l
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-24 02:13:38 +00:00
|
|
|
class License(ItfModel):
|
2010-11-29 13:02:19 +00:00
|
|
|
letter = models.CharField(max_length=2)
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
short_description = models.TextField()
|
|
|
|
readable_file = models.FileField(upload_to='upload/licenses/short/')
|
|
|
|
legal_file = models.FileField(upload_to='upload/licenses/legal/')
|
2011-10-13 14:40:45 +00:00
|
|
|
typ = models.CharField(choices=LICENSE_TYPE_CHOICES, max_length=32)
|
2010-11-29 13:02:19 +00:00
|
|
|
|
2011-10-24 02:13:38 +00:00
|
|
|
title_field = 'name'
|
|
|
|
|
2010-11-29 13:02:19 +00:00
|
|
|
def __unicode__(self):
|
2011-10-13 14:40:45 +00:00
|
|
|
return self.typ + ": " + self.letter + ": " + self.name
|
2010-11-29 13:02:19 +00:00
|
|
|
|
2011-10-24 02:13:38 +00:00
|
|
|
def list_dict(self):
|
|
|
|
return {
|
|
|
|
'id': self.id,
|
|
|
|
'title': self.name
|
|
|
|
}
|
|
|
|
|
|
|
|
def info_dict(self):
|
|
|
|
return {
|
|
|
|
'id': self.id,
|
|
|
|
'letter': self.letter,
|
|
|
|
'short_description': self.short_description,
|
|
|
|
'readable_file': self.readable_file.url,
|
|
|
|
'legal_file': self.legal_file.url,
|
2011-10-24 02:20:12 +00:00
|
|
|
'typ': self.typ,
|
|
|
|
'reviews': Review.objects.filter(script=self)
|
2011-10-24 02:13:38 +00:00
|
|
|
}
|
2010-11-29 13:02:19 +00:00
|
|
|
|
|
|
|
class Review(models.Model):
|
|
|
|
script = models.ForeignKey(Script)
|
|
|
|
reviewer = models.CharField(max_length=255)
|
|
|
|
reviewer_email = models.EmailField()
|
|
|
|
text = models.TextField()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#this is to record who downloaded what play, etc.
|
|
|
|
class Downloader(models.Model):
|
|
|
|
script = models.ForeignKey(Script)
|
|
|
|
email = models.EmailField()
|
|
|
|
|
|
|
|
##Make sure to add Comments to scripts
|
|
|
|
|
|
|
|
|