From e5dc1c48ea48177e21cff6670a2dbf0c4c4cf262 Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Fri, 10 Aug 2012 06:21:15 +0530 Subject: Feature : Add tag to email threads --- hyperkitty/models.py | 15 ++++++++++- hyperkitty/templates/thread.html | 19 ++++++++++++- hyperkitty/templates/threads/add_tag_form.html | 2 +- hyperkitty/templates/threads/right_col.html | 3 ++- hyperkitty/urls.py | 4 +-- hyperkitty/views/list.py | 27 ++++++++++++------- hyperkitty/views/thread.py | 37 +++++++++++++------------- 7 files changed, 74 insertions(+), 33 deletions(-) (limited to 'hyperkitty') diff --git a/hyperkitty/models.py b/hyperkitty/models.py index f1bc196..dc1bcb4 100644 --- a/hyperkitty/models.py +++ b/hyperkitty/models.py @@ -59,7 +59,7 @@ class UserProfile(models.Model): "Returns all the votes by a user" # Extract all the votes by this user try: - votes = Rating.objects.filter(user = self.user) + votes = Rating.objects.filter(user=self.user) except Rating.DoesNotExist: votes = {} @@ -75,3 +75,16 @@ class UserProfile(models.Model): def __unicode__(self): """Unicode representation""" return u'%s' % (unicode(self.user)) + +class Tag(models.Model): + # @TODO: instead of list_address, user list model from kittystore? + list_address = models.CharField(max_length=50) + + # @TODO: instead of threadid, use thread model from kittystore? + threadid = models.CharField(max_length=100) + + tag = models.CharField(max_length=255) + + def __unicode__(self): + """Unicode representation""" + return u'threadid = %s , tag = %s ' % (unicode(self.list_address), unicode(self.threadid)) diff --git a/hyperkitty/templates/thread.html b/hyperkitty/templates/thread.html index a1bc38c..20248f1 100644 --- a/hyperkitty/templates/thread.html +++ b/hyperkitty/templates/thread.html @@ -93,7 +93,24 @@ }); + $("#add_tag_form").submit( function () { + + {% if user.is_authenticated %} + $.ajax({ + type: "POST", + data : $(this).serialize(), + url: "{% url add_tag mlist_fqdn=list_address, email_id=first_mail.message_id %}", + success: function(data){ + console.log('Tag is added successfully'); + } + }); + return false; + {% else %} + alert('You need to login in order to add tag'); + {% endif %} + }); + + }); - {% endblock %} diff --git a/hyperkitty/templates/threads/add_tag_form.html b/hyperkitty/templates/threads/add_tag_form.html index 65f6577..9df2196 100644 --- a/hyperkitty/templates/threads/add_tag_form.html +++ b/hyperkitty/templates/threads/add_tag_form.html @@ -3,7 +3,7 @@ {% block header %} {% endblock %} {% block content %} -
+ {% csrf_token %} {{ addtag_form }}