summaryrefslogtreecommitdiff
path: root/stapp
diff options
context:
space:
mode:
authorjayparikh1112012-07-25 20:24:28 +0530
committerjayparikh1112012-07-25 20:24:28 +0530
commit2da8081f73a42aedf0441e09ac9e41bda4133721 (patch)
tree3982d88921df79b8bba8b98aa3f6d9d26efc9d62 /stapp
parent8a205b00cc49ae7a935889f6f19e2ffcd0cf3c2d (diff)
downloadstproject-2da8081f73a42aedf0441e09ac9e41bda4133721.tar.gz
stproject-2da8081f73a42aedf0441e09ac9e41bda4133721.tar.bz2
stproject-2da8081f73a42aedf0441e09ac9e41bda4133721.zip
added tagging facility
Diffstat (limited to 'stapp')
-rw-r--r--stapp/settings.py2
-rw-r--r--stapp/templates/video/home.html3
-rw-r--r--stapp/urls.py2
-rw-r--r--stapp/video/models.py3
-rw-r--r--stapp/video/urls.py2
-rw-r--r--stapp/video/views.py13
6 files changed, 21 insertions, 4 deletions
diff --git a/stapp/settings.py b/stapp/settings.py
index 63e4b78..f56e2e8 100644
--- a/stapp/settings.py
+++ b/stapp/settings.py
@@ -112,7 +112,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
-
+ 'taggit',
'south',
'video',
diff --git a/stapp/templates/video/home.html b/stapp/templates/video/home.html
index 3b95d4e..ab17ca1 100644
--- a/stapp/templates/video/home.html
+++ b/stapp/templates/video/home.html
@@ -17,6 +17,9 @@ function changeDetail(video,image,idname,iddesc)
{% block onload %} {% endblock onload %}
{% block video %}
+{% for tag in tags %}
+ <a href="/tags/{{tag}}/">{{tag}}</a>
+{% endfor %}
<video style="border:2px solid black;" width="100%" controls="controls" id="mainvideo" poster="{{play.image.url}}" preload="none" src="{{play.filename.url}}">
</video>
diff --git a/stapp/urls.py b/stapp/urls.py
index 219148b..53a1474 100644
--- a/stapp/urls.py
+++ b/stapp/urls.py
@@ -8,7 +8,7 @@ from video.views import *
admin.autodiscover()
urlpatterns = patterns('',
- url(r'^$', include('video.urls')),
+ url(r'^', include('video.urls')),
url(r'^admin/', include(admin.site.urls)),
)
diff --git a/stapp/video/models.py b/stapp/video/models.py
index cfbf2aa..0f79ca7 100644
--- a/stapp/video/models.py
+++ b/stapp/video/models.py
@@ -1,6 +1,7 @@
from django.db import models
from django.db.models.signals import post_delete
from signals import delete_files
+from taggit.managers import TaggableManager
import settings
@@ -26,6 +27,7 @@ class Video(models.Model):
image = models.ImageField(upload_to=get_image_path)
description = models.TextField()
created = models.DateTimeField(auto_now_add=True)
+ tags = TaggableManager()
def __unicode__(self):
return self.name
@@ -41,6 +43,7 @@ class Module(models.Model):
video_list = models.ManyToManyField(Video)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField()
+ tags = TaggableManager()
def save(self, *args, **kwargs):
''' On save, update timestamps '''
diff --git a/stapp/video/urls.py b/stapp/video/urls.py
index e45cb7c..3972d6e 100644
--- a/stapp/video/urls.py
+++ b/stapp/video/urls.py
@@ -3,5 +3,7 @@ from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('video.views',
url(r'^$', 'show'),
url(r'^view/(?P<video_id>\d+)/$', 'show'),
+ url(r'^tags/$','show_tags_video'),
+ url(r'^tags/(?P<tag_name>[a-zA-Z0-9_.]+)/$', 'show_tags_video'),
)
diff --git a/stapp/video/views.py b/stapp/video/views.py
index 8b7240d..d517c74 100644
--- a/stapp/video/views.py
+++ b/stapp/video/views.py
@@ -2,6 +2,7 @@ from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import render, get_object_or_404, redirect
from video.models import Video, Module
+from taggit.models import Tag
def show(request):
videos = Video.objects.all()
@@ -14,8 +15,16 @@ def show(request):
#Get last three modified modules
latest_modules = Module.objects.order_by('-modified')[0:3]
all_modules = Module.objects.order_by('modified')
+ tags = Tag.objects.all()
-
- context = { 'latest_modules' : latest_modules , 'play' : latest_video, 'all_modules':all_modules}
+ context = { 'latest_modules' : latest_modules , 'play' : latest_video, 'all_modules':all_modules,'tags':tags}
return render(request, 'video/home.html', context)
+
+def show_tags_video(request,tag_name=None):
+ if tag_name==None:
+ return redirect('/')
+ videos = Video.objects.filter(tags__name__in=[tag_name])
+ context = {'videos':videos}
+ return render(request,'video/tag_video.html',context)
+