~loco-django-dev/loco-django/trunk

« back to all changes in this revision

Viewing changes to locodjango/navigation/models.py

  • Committer: NerdyNick
  • Date: 2007-10-26 04:52:01 UTC
  • Revision ID: nerdynick@gmail.com-20071026045201-4hrnxmnpddf46s63
Improved the Navigation system
        Now supports categories
        PageCategory 1 is the default menu system
        The first page in the default menu is the default page for the website
        A RequestContext variable has been added containing a dictionary of all categories and there pages
                Check locodjango.navigation.views.siteMenu for an example of how to push it into your template
                Check /template/default/sitemenu.htm for example usage of the links dictionary in a template
                Note: You will need to follow the same render_to_string shortcut for all views in order to keep you navigation on all pages
OpenID support has been started
Default template media has been included into the /template/default/media folder.
        A Symbolic link or apache virtual directory will need to be added to your apache root directory for the site

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from django.db import models
2
2
from django.contrib.flatpages.models import FlatPage
3
3
 
 
4
class PageCategory(models.Model):
 
5
    name = models.CharField(max_length = 255)
 
6
    
 
7
    def __unicode__(self):
 
8
        return self.name
 
9
    
 
10
    class Meta:
 
11
        verbose_name = 'Link/Page Category'
 
12
        verbose_name_plural = 'Link/Page Categories'
 
13
        ordering = ('name',)
 
14
    
 
15
    class Admin:
 
16
        list_display = ('id', 'name')
 
17
        list_display_links = ('id', 'name')
 
18
 
4
19
class Page(models.Model):
5
20
    name = models.CharField(max_length = 255)
6
21
    url = models.CharField(blank = True, help_text = 'This is the URL of the Page', max_length = 200)
7
22
    order = models.SmallIntegerField(blank = True, null = True, help_text = 'In what order would you like your pages. Note: The first item will be the default page displayed')
8
23
    flatpage = models.ForeignKey(FlatPage, blank = True, null = True, help_text = 'If you would like to use a flatpage instead of a URL. Select the page here. Note: The URL field will be ignored if this is provided')
9
 
    ordering = ['order']
 
24
    category = models.ForeignKey(PageCategory, blank = True, null = True, help_text = 'This is the category you wish to have the page belong to. Note: Select default to add to main menu.')
10
25
    
11
26
    def GetURL(self):
12
27
        """ 
17
32
        try:
18
33
            return self.flatpage.url
19
34
        except Exception, E:
20
 
            return self.uri
 
35
            return self.url
21
36
    
22
37
    def __unicode__(self):
23
38
        return self.name
24
39
    
 
40
    class Meta:
 
41
        ordering = ('category', 'name')
 
42
        order_with_respect_to = 'category'
 
43
        verbose_name = 'Link/Page'
 
44
        verbose_name_plural = 'Links/Pages'
 
45
        
25
46
    class Admin:
26
 
        list_display = ('name', 'url', 'flatpage', 'order')
 
 
b'\\ No newline at end of file'
 
47
        list_display = ('name', 'url', 'flatpage', 'order', 'category')
 
 
b'\\ No newline at end of file'