Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # models.py
- from django.utils.translation import ugettext_lazy as _
- from django.db import models
- from django.contrib.auth.models import User
- class Agenda( models.Model ):
- """
- Holds the details for an Agenda posted by submitter
- """
- title = models.CharField( verbose_name=_( "Title" ), blank=False )
- content = models.CharField( verbose_name=_( "Agenda Description" ), blank=False )
- author = models.ForeignKey( User, verbose_name=_( "Author" ), blank=False )
- created = models.DateTimeField( auto_now_add=True, verbose_name=_( "Creation Time" ), blank=False )
- VoteID = models.PositiveInteger()
- UserID = models.PositiveInteger()
- User = models.CharField(max_lenth=32)
- Submitted = models.DateTimeField()
- End = models.DateTimeField()
- def __unicode__( self ):
- return self.title
- @models.permalink
- def get_absolute_url( self ):
- return ( "aur2:detail", ( ), { "object_id" : self.id } )
- # urls.py
- urlpatterns = patterns(
- ...
- url( r'agendas/', include( 'aur2.urls', namespace="aur2" ) ),
- ...
- )
- # aur2/urls.py
- from django.conf.urls.defaults import *
- urlpatterns = patterns(
- # voting urls from reddit example
- # Generic view to list Agenda objects
- url(r'^$', 'django.views.generic.list_detail.object_list', dict(queryset=Agenda.objects.all(),
- template_object_name='agenda', template_name='aur2/agenda_list.html',
- paginate_by=15, allow_empty=True), name='list'),
- url(r'^new$', 'django.views.generic.create_update.create_object', dict(model=Agenda), name='new'),
- url(r'^edit/(?P<object_id>\d+)$', 'django.views.generic.create_update.update_object' dict(model=Agenda),, name='edit'),
- url(r'^(?P<object_id>\d+)$', 'django.views.generic.list_detail.object_detail', dict(template_object_name='agenda', template_name='aur2/agenda_detail.html', model=Agenda), name='detail'),
- # Generic view to vote on Link objects
- url(r'^(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/?$',
- 'voting.views.vote_on_object', dict(model=Agenda, template_object_name='agenda',
- template_name='aur2/agenda_confirm_vote.html',
- allow_xmlhttprequest=True), name='vote'),
- )
Add Comment
Please, Sign In to add comment