This commit is contained in:
Karen 2012-11-02 18:35:19 +05:30
commit 003cff91ea
6 changed files with 69 additions and 101 deletions

View File

@ -39,6 +39,13 @@ class TheatreGroupAdmin(admin.ModelAdmin):
save_on_top = True
#class LocationAdmin(admin.ModelAdmin):
# save_on_top = True
class CityAdmin(admin.ModelAdmin):
pass
admin.site.register(Occupation, OccupationAdmin)
admin.site.register(Relation, RelationAdmin)
admin.site.register(TheatreGroup, TheatreGroupAdmin)
@ -46,6 +53,8 @@ admin.site.register(Person)
admin.site.register(Language)
admin.site.register(Training)
admin.site.register(Production)
#admin.site.register(Location,LocationAdmin)
admin.site.register(City,CityAdmin)
#class TalkAdmin(admin.ModelAdmin):
# inlines = [PadmaVideoInline, AudioInline, ImageInline, DocumentInline]

View File

@ -29,7 +29,6 @@ class LocationForm(ItfForm):
LocationsInline = itf_inlineformset_factory(Location, form=LocationForm, title="Locations", is_generic=True)
class BuzzItemsForm(ItfForm):
class Meta:
@ -92,7 +91,7 @@ class PopupProductionForm(PopupForm):
class Meta:
model = Production
fields = ('name', 'group',)
fields = ('name', 'group',)
#Inline form definitions and inlines for Person form
@ -115,6 +114,15 @@ class PersonProductionForm(ItfForm):
class Meta:
model = PersonProduction
class TheatreGroupProductionForm(ItfForm):
#j pass an empty list,
#production = forms.ModelChoiceField([], widget=AutocompleteAddWidget(model_class=Production))
class Meta:
model = Production
ProductionsTheatreGroupInline = itf_inlineformset_factory(TheatreGroup, Production, form=TheatreGroupProductionForm, extra=1, title="Productions")
class PersonGroupForm(ItfForm):
group = forms.ModelChoiceField(TheatreGroup.objects.all(), widget=AutocompleteAddWidget(model_class=TheatreGroup))
@ -123,6 +131,7 @@ class PersonGroupForm(ItfForm):
ConnectionsInline = itf_inlineformset_factory(Person, PersonPerson, fk_name='person1', form=ConnectionsForm, extra=1, title="Add / Edit Connections", help_text="select the people you are connected with and how you are related in the theatre world")
ProductionsInline = itf_inlineformset_factory(Person, PersonProduction, form=PersonProductionForm, extra=1, title="Productions you have worked in")
GroupsInline = itf_inlineformset_factory(Person, PersonGroup, extra=1, form=PersonGroupForm, title="Theatre groups you are a part of or have worked with")
PersonOccupationsInline = itf_inlineformset_factory(Person, PersonOccupation, extra=1, form=PersonOccupationForm, title="Select your occupation / you can add as many as you like")
@ -176,7 +185,7 @@ GroupOccupationInline = itf_inlineformset_factory(TheatreGroup, GroupGroupOccupa
class TheatreGroupForm(ItfForm):
languages = forms.ModelMultipleChoiceField(Language.objects.all(), widget=forms.CheckboxSelectMultiple())
inlines = [GroupOccupationInline, PersonGroupInline, ResourcesInline, BuzzItemsInline, AwardsInline, TrainingsInline, LocationsInline]
inlines = [GroupOccupationInline, PersonGroupInline, ResourcesInline, BuzzItemsInline, AwardsInline, TrainingsInline, LocationsInline, ProductionsTheatreGroupInline]
class Meta:
model = TheatreGroup
@ -213,11 +222,26 @@ class ItfAllAuthRegForm(forms.Form):
firstname=forms.CharField()
lastname=forms.CharField()
def save(self, user):
#def __init__(self, request=None):
def save(self, user, request=None):
first_name = self.cleaned_data['firstname']
last_name = self.cleaned_data['lastname']
p = Person(user=user, first_name=first_name, last_name=last_name, email=user.email)
p.save()
if request.session['invite_code']:
invite_code = request.session['invite_code']
pi = PersonInvitation.objects.get(invite_code=invite_code)
inviter = pi.inviter
invitee = pi.invitee
invitee.user=user
invitee.save()
else:
p = Person(user=user, first_name=first_name, last_name=last_name, email=user.email)
p.save()
user.first_name = first_name
user.last_name = last_name
user.save()
return self

View File

@ -138,19 +138,18 @@ class PersonInvitation(models.Model):
invitee = models.ForeignKey(Person, related_name='was_invited_by', null=True, blank=True)
is_validated=models.BooleanField(default=False)
sent_date = models.DateTimeField()
def __unicode__(self):
return u'%s, %s' % (self.invitee.first_name, self.invitee.email)
def send(self):
def send_mail(self):
#import pdb ; pdb.set_trace()
#from django.template.loader import get_template
template = get_template('modules/itfprofiles/invitation_email.txt')
subject = 'Invitation to join the India Theatre Forum'
template = get_template('/itfprofiles/invitation_email.txt')
link = 'http://%s/invitation/accept/%s/' % ( "test.theatreforum.in", self.invite_code, )
context = Context({
'name': str(self.invitee.first_name) + str(self.invitee.last_name),
'link': link,
'sender': str(self.inviter.first_name) + str(self.inviter.last_name),
'sender': str(self.inviter.first_name) + str(self.inviter.last_name)
})
message = template.render(context)
send_mail(
@ -158,6 +157,11 @@ class PersonInvitation(models.Model):
DEFAULT_FROM_MAIL, [self.invitee.email]
)
def __unicode__(self):
return u'%s, %s' % (self.invitee.first_name, self.invitee.email)
class BuzzItem(ItfModel):
link = models.URLField(verify_exists=False)
@ -207,18 +211,20 @@ STATE_CHOICES= (
('31', 'Tripura'),
('32', 'Uttarakhand (Uttaranchal)'),
('33', 'Uttar Pradesh'),
('34', 'West Bengal')
('34', 'West Bengal'),
('35', 'Not Applicable'),
)
class City(models.Model):
name = models.CharField(max_length=255)
state = models.CharField(choices = STATE_CHOICES, max_length=255)
def __unicode__(self):
return self.name
from django.contrib.localflavor.in_.forms import INZipCodeField
class Location(models.Model):
lat= models.FloatField(blank=True, null=True)
lon= models.FloatField(blank=True, null=True)
#lat= models.FloatField(blank=True, null=True)
#lon= models.FloatField(blank=True, null=True)
city = models.ForeignKey(City)
pincode= INZipCodeField()
address= models.TextField()
@ -254,6 +260,7 @@ class Training(models.Model):
person = models.ForeignKey("Person")
area = models.CharField(max_length=255)
with_whom = models.CharField(max_length=255) # Is this a foreign key to person, or group, or just text field like now?
#trained_by=models.ManyToManyField('Person', related_name='trained')
where = models.ForeignKey("TheatreGroup")
from_when = models.DateField(blank=True, null=True)
until_when = models.DateField(blank=True, null=True)

View File

@ -1,13 +1,13 @@
# Create your views here.
from models import *
from forms import *
from django.shortcuts import render_to_response
from django.shortcuts import render_to_response, get_object_or_404
from ox.django.shortcuts import render_to_json_response
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.template import RequestContext
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from datetime import datetime
def person_form(request):
@ -49,7 +49,8 @@ def edit_profile(request):
})
return render_to_response("test/person_form.html", context)
@login_required
@csrf_exempt
@login_required
def friend_invite(request):
if request.method == 'POST':
form = PersonForm(request.POST, request.FILES)
@ -62,11 +63,11 @@ def friend_invite(request):
inviter=Person.objects.get(user=request.user),
sent_date=datetime.now()
)
invitation.send()
try:
invitation.save()
except:
return HttpResponse("<html><body>Not Invited!!</body></html>")
invitation.save()
#try:
invitation.send_mail()
#except:
# return HttpResponse("<html><body>Not Invited!!</body></html>")
return HttpResponse("<html><body>Invited!!</body></html>")
#return HttpResponseRedirect('/invitation/invite/')
@ -83,9 +84,9 @@ def friend_invite(request):
def invitation_accept(request,invite_code):
invitation = get_object_or_404(PersonInvitation, invite_code__exact=invite_code)
request.session['invitation'] = invitation.id
return HttpResponseRedirect('/accounts/madd')
#invitation = get_object_or_404(PersonInvitation, invite_code__exact=invite_code)
request.session['invite_code'] = invite_code
return HttpResponseRedirect('/accounts/signup')

View File

@ -1,73 +0,0 @@
<link rel="stylesheet" href="/static/css/modules/tabsinnerright.css" type="text/css" />
<ul class="tabsInnerRight">
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#productions">Productions</a></li>
<li><a href="#people">People</a></li>
<li><a href="#notes">Notes</a></li>
<li><a href="#gallery">Gallery</a></li>
<li><a href="#resources">Resources</a></li>
<li><a href="#licenses">Licenses</a></li>
<li><a href="#licenses">Authors</a></li>
</ul>
<div id="synopsis" class="tab_content">
<h3>Script Name</h3>
<p> <span class="orange"> Writer: </span>Names of writers</p>
<p> <span class="orange"> Language(s): </span>Hindi, Bengali</p>
<p> <span class="orange"> Approximate duration: </span></p>
<p> <span class="orange"> No of characters: </span>20; Female: 5, Male: 15</p>
<br>
<div>
<p class="orange">Synopsis</p>
<p>Some copy here that is a synopsis in a paragraph. Some copy here that is a synopsis in a paragraph.
Some copy here that is a synopsis in a paragraph. Some copy here that is a synopsis in a paragraph.</p>
</div>
<p><strong>This script may be accessed
under the following Creative Commons Licenses:</strong></p>
<p class="orange">Adaptation License: Derivative Works allowed</p>
<p>Some license information. <span style="color:red;">Does this need to be an accordion?</span></p>
<p class="orange">Read legal license</p>
<p class="orange">Performance License: Derivative Works allowed</p>
<img href={{ image.get_absolute_url }} </img>
<a href="">Download</a>
</div> <!-- end synopsis -->
<div id="gallery" class="tab_content">
<div class="imgVideoBlock">
<h3 class="orange">Photos</h3>
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<a href="" class="moreLink">More&raquo;</a>
</div>
<br>
<div class="imgVideoBlock">
<h3 class="orange">Videos</h3>
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<img src="/static/images/150x150.jpg" width="160" height="120" alt="" />
<a href="" class="moreLink">More&raquo;</a>
</div>
</div> <!-- end gallery -->
<script type="text/javascript" src="/static/js/innertabs.js"></script>

View File

@ -57,7 +57,7 @@ urlpatterns = patterns('',
(r'emailsignuplist', 'festival.views.email_signups'),
(r'^favicon.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}),
(r'^invitation/(w+)/$','itfprofiles.views.invitation_accept'),
(r'^invitation/accept/(?P<invite_code>\w+)/','itfprofiles.views.invitation_accept'),
#(r'^invitation/add/$', 'itfprofiles.views.friend_add'),
(r'^invitation/invite/$', 'itfprofiles.views.friend_invite'),
)