From 2d650f1d23b8ec81ab1691b81fb5edea4320be51 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 31 Jul 2012 18:35:22 +0530 Subject: [PATCH] add add / edit links --- itf/app/models.py | 7 +++++++ itf/insidepages/views.py | 5 ++++- itf/templates/modules/itfprofiles/theatregroup.html | 3 +++ itf/templates/modules/scriptbank/script.html | 5 ++++- itf/templates/noel/render_object.html | 4 +++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/itf/app/models.py b/itf/app/models.py index 4f0636e..e6ab8f4 100755 --- a/itf/app/models.py +++ b/itf/app/models.py @@ -167,6 +167,13 @@ class ItfModel(models.Model): ''' return "%s/%s/%d/edit" % (self.get_module().get_absolute_url(), self.get_tab().slug, self.id) + + def get_add_url(self): + if hasattr(self, 'main_form'): + return "%s/%s/add" % (self.get_module().get_absolute_url(), self.get_tab().slug,) + else: + return None + ''' Get insidepages.models.Module instance for this object ''' diff --git a/itf/insidepages/views.py b/itf/insidepages/views.py index 7a7108c..3f12d65 100755 --- a/itf/insidepages/views.py +++ b/itf/insidepages/views.py @@ -143,12 +143,15 @@ def render_object(request, module_slug): else: #We create a 'fake' object with properties that we require the template to render No results found, FIXME: should be a cleaner way to perhaps render a separate template with the list of items on the left and saying "No Results Found" - however, this works for now. obj = { 'get_title': 'No Results Found', - 'get_absolute_url': tab.get_absolute_url() + 'get_absolute_url': tab.get_absolute_url(), + 'get_add_url': None } item_data = { 'html': 'The search query you entered did not return any results.' } + + #Get all the context and render to template context = RequestContext(request, { 'item': obj, #The object to be rendered diff --git a/itf/templates/modules/itfprofiles/theatregroup.html b/itf/templates/modules/itfprofiles/theatregroup.html index e69de29..0e0bc57 100644 --- a/itf/templates/modules/itfprofiles/theatregroup.html +++ b/itf/templates/modules/itfprofiles/theatregroup.html @@ -0,0 +1,3 @@ + +
+Edit diff --git a/itf/templates/modules/scriptbank/script.html b/itf/templates/modules/scriptbank/script.html index 39740dd..153e29b 100755 --- a/itf/templates/modules/scriptbank/script.html +++ b/itf/templates/modules/scriptbank/script.html @@ -4,4 +4,7 @@ Synopsis: {{ synopsis }}
{% endif %} -Download +Download

+ +
+Edit diff --git a/itf/templates/noel/render_object.html b/itf/templates/noel/render_object.html index 4072873..2b251e7 100755 --- a/itf/templates/noel/render_object.html +++ b/itf/templates/noel/render_object.html @@ -96,8 +96,10 @@ About {% comment %} - {% if has_add %} + {% if item.get_add_url %} + About + {% endif %} {% endcomment %}