merged
This commit is contained in:
commit
7c793fed09
|
@ -78,7 +78,14 @@ class ItfModel(models.Model):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def add_note(self, user, text):
|
||||
if self.user_has_perms(user):
|
||||
n = Note(user=user, text=text, content_object=self)
|
||||
n.save()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
#Should return the id for the object and the title to display in the left hand list
|
||||
def list_dict(self):
|
||||
|
@ -106,6 +113,7 @@ class ItfModel(models.Model):
|
|||
# d['add_form'] = self.__class__.get_add_form()
|
||||
d['forms'] = self.__class__.get_forms()
|
||||
d['obj'] = self
|
||||
d['content_type'] = ContentType.objects.filter(model=self.__class__._meta.module_name)[0]
|
||||
try:
|
||||
edit_url = self.get_edit_url()
|
||||
d['edit_url'] = edit_url
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.contrib.localflavor.in_.forms import INZipCodeField
|
|||
#from ox.django.fields import DictField
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.contenttypes import generic
|
||||
from itfprofiles.models import City, Location, Production, TheatreGroup, Person, BuzzItem
|
||||
from itfprofiles.models import City, Location, Production, TheatreGroup, Person, BuzzItem, Note
|
||||
from mediagallery.models import GalleryAlbum
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@ class Event(ItfModel):
|
|||
production = models.ForeignKey(Production, blank=True, null=True, help_text="If this is a showing of a production...")
|
||||
buzzitems = generic.GenericRelation(BuzzItem)
|
||||
galleries = generic.GenericRelation(GalleryAlbum)
|
||||
notes = generic.GenericRelation(Note)
|
||||
people = models.ManyToManyField(Person, blank=True, null=True, through="PersonEvent")
|
||||
image = models.ImageField(upload_to='images/', blank=True, null=True)
|
||||
groups = models.ManyToManyField(TheatreGroup, blank=True, null=True, through="GroupEvent")
|
||||
|
@ -49,6 +50,16 @@ class Event(ItfModel):
|
|||
#Entities and Connections -
|
||||
# connections = generic.GenericRelation("Connection")
|
||||
|
||||
def user_has_perms(self, user):
|
||||
if ItfModel.user_has_perms(self, user):
|
||||
return True
|
||||
for pe in self.personevent_set.filter(typ='organiser'):
|
||||
if pe.person == user:
|
||||
return True
|
||||
for ge in self.groupevent_set.filter(typ='venue'):
|
||||
if ge.user_has_perms(user):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __unicode__(self):
|
||||
return "%s" % (self.title,)
|
||||
|
|
|
@ -195,6 +195,16 @@ class BuzzItem(ItfModel):
|
|||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
class Note(ItfModel):
|
||||
user = models.ForeignKey(User)
|
||||
text = models.TextField()
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
||||
|
||||
def __unicode__(self):
|
||||
return self.text
|
||||
|
||||
|
||||
STATE_CHOICES= (
|
||||
|
@ -322,7 +332,7 @@ class TheatreGroup(ItfModel):
|
|||
awards = generic.GenericRelation("Award")
|
||||
buzzitems = generic.GenericRelation("BuzzItem")
|
||||
galleries = generic.GenericRelation(GalleryAlbum)
|
||||
|
||||
notes = generic.GenericRelation("Note")
|
||||
website = models.URLField(blank=True, verify_exists=False)
|
||||
resources = generic.GenericRelation("Resource")
|
||||
locations = generic.GenericRelation("Location")
|
||||
|
@ -427,6 +437,7 @@ class Production(ItfModel):
|
|||
awards = generic.GenericRelation("Award")
|
||||
debut_date = models.DateField(blank=True, null=True)
|
||||
reviews= generic.GenericRelation("BuzzItem")
|
||||
notes = generic.GenericRelation("Note")
|
||||
galleries = generic.GenericRelation(GalleryAlbum)
|
||||
#FIXME: add no of shows
|
||||
|
||||
|
|
|
@ -164,6 +164,8 @@ def contact_person(request):
|
|||
|
||||
|
||||
def contact_group(request):
|
||||
if not request.user.is_authenticated():
|
||||
return HttpResponse("You need to be logged in to send messages")
|
||||
frm = request.user.email
|
||||
to_group = request.GET.get("to", None)
|
||||
try:
|
||||
|
@ -182,3 +184,15 @@ def contact_group(request):
|
|||
return HttpResponse("Your message has been sent, thanks.")
|
||||
|
||||
|
||||
def add_note(request, content_type, object_id):
|
||||
model_class = ContentType.objects.get(pk=content_type).model_class()
|
||||
obj = model_class.objects.get(pk=object_id)
|
||||
if not obj.user_has_perms(request.user):
|
||||
return render_to_json_response({'error': 'You do not have permissions to add a note'})
|
||||
note = request.POST.get("note", None)
|
||||
if note:
|
||||
obj.add_note(request.user, note)
|
||||
return render_to_json_response({'success': 'Note added'})
|
||||
else:
|
||||
return render_to_json_response({'error': 'Empty note'})
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@
|
|||
{% endif %}
|
||||
|
||||
<div id="notes" class="tab_content">
|
||||
<h3 class="orange">Kindly refer to notes tab in Script Archive</h3>
|
||||
{% include 'includes/notes.html' %}
|
||||
</div> <!-- end notes -->
|
||||
|
||||
<script type="text/javascript" src="/static/js/innertabs.js"></script>
|
||||
|
|
|
@ -63,6 +63,7 @@ urlpatterns = patterns('',
|
|||
(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'),
|
||||
(r'^add_note/(?P<content_type>[0-9]*?)/(?P<object_id>[0-9]*?)$', 'itfprofiles.views.add_note'),
|
||||
(r'^contact/person/$', 'itfprofiles.views.contact_person'),
|
||||
(r'^contact/group/$', 'itfprofiles.views.contact_group'),
|
||||
(r'^contact/event/$', 'events.views.contact_person'),
|
||||
|
|
Loading…
Reference in New Issue
Block a user