0% found this document useful (0 votes)
13 views1 page

SVN Sphene Frameworkcomparison Django Barsite Barcrud Models

Barcrud is a django framework for building a bar site. It's based on sphene's barcrud framework. Models is a model of a bar with a name and a location.

Uploaded by

ms6675
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

SVN Sphene Frameworkcomparison Django Barsite Barcrud Models

Barcrud is a django framework for building a bar site. It's based on sphene's barcrud framework. Models is a model of a bar with a name and a location.

Uploaded by

ms6675
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

12/6/2014 source.sphene.net/svn/sphene/frameworkcomparison/django/barsite/barcrud/models.

py
http://source.sphene.net/svn/sphene/frameworkcomparison/django/barsite/barcrud/models.py 1/1
from django.db import models
from django.db.models import permalink
from django.contrib.auth.models import User
from datetime import datetime
# Create your models here.
WIFI_CHOICES = (
( 'y', 'yes', ),
( 'n', 'no', ),
( 'p', 'paid', ),
)
class Bar(models.Model):
name = models.CharField(max_length=250)
location = models.CharField(max_length=250)
wifi = models.CharField(max_length=1, choices = WIFI_CHOICES)
creationdate = models.DateTimeField()
editdate = models.DateTimeField()
lasteditor = models.ForeignKey(User)
def save(self):
"""
Saves this bar - callers have to set 'lasteditor' by hand tough !
"""
if not self.id:
self.creationdate = datetime.today()
self.editdate = datetime.today()
return super(Bar, self).save()
@permalink
def get_absolute_url(self):
return ('barcrud.views.details', (), { 'bar_id': self.id })
class Meta:
ordering = ['name']
class Beer(models.Model):
name = models.CharField(max_length = 250)
class Admin:
pass
class BarBeer(models.Model):
bar = models.ForeignKey(Bar)
beer = models.ForeignKey(Beer)
class Comment(models.Model):
bar = models.ForeignKey(Bar)
author = models.ForeignKey(User)
date = models.DateTimeField()
comment = models.TextField()
def save(self):
self.date = datetime.today()
return super(Comment, self).save()
class Meta:
ordering = [ '-date' ]

You might also like