add add / edit links

This commit is contained in:
Sanj 2012-07-31 18:35:22 +05:30
parent 6cd0b65fe8
commit 2d650f1d23
5 changed files with 21 additions and 3 deletions

View File

@ -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
'''

View File

@ -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

View File

@ -0,0 +1,3 @@
<br />
<a href="{{ edit_url }}">Edit</a>

View File

@ -4,4 +4,7 @@
<span class="orange">Synopsis: </span> {{ synopsis }} <br />
{% endif %}
<a class="bpRelated" href="{{ script_file }}">Download</a>
<a class="bpRelated" href="{{ script_file }}">Download</a> <br /><br />
<br />
<a href="{{ edit_url }}">Edit</a>

View File

@ -96,8 +96,10 @@
<!--<img src="/static/images/noel/search-inner.png" width="22" height="18" alt="search" class="searchInner">-->
<img src="/static/images/noel/about.png" width="22" height="22" id="aboutBtn" alt="About" title="About">
{% comment %}
{% if has_add %}
{% if item.get_add_url %}
<a href="{{ item.get_add_url }}">
<img src="/static/images/noel/add.png" width="28" height="20" id="addBtn" alt="About" title="Add">
</a>
{% endif %}
{% endcomment %}