Skip to content

Commit

Permalink
various updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nikcub committed Sep 13, 2011
1 parent 7e6077b commit 24a4b95
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -41,3 +41,4 @@ Easy!
@TODO comments / users / moderation
@TODO multi templates
@TODO support multiple URLs (ie. stub changed) with list of 'old' to match and redirect
@TODO timezone support with pytz (import pytz)
1 change: 0 additions & 1 deletion buckley/controller.py
Expand Up @@ -91,7 +91,6 @@ def get_response_type(self):
if not self.request.headers.has_key('accept'):
return 'html'


accept = self.request.headers['accept'].split(',')
if accept[0] == 'application/json' or self.request.get('json'):
return 'json'
Expand Down
10 changes: 5 additions & 5 deletions buckley/controllers/__init__.py
@@ -1,7 +1,7 @@

from posts import *
# from archive import *
# from feed import *
# from pages import *
# from projects import *
# from admin import *
from archive import *
from feed import *
from pages import *
from projects import *
from admin import *
24 changes: 24 additions & 0 deletions buckley/models/group.py
@@ -0,0 +1,24 @@

class Group(db.Model):
name = db.StringProperty()


class Membership(db.Model):
user = db.ReferenceProperty(User)
group = db.ReferenceProperty(Group)
group_name = db.StringProperty()

def put(self):
self.group_name = self.group.name
super(Membership, self).put()

def get_group(self, name):
return [n.group for n in user.membership_set.order('group_name')]

@classmethod
def create(username, groupname):
Super(Membership, user = username, group = groupname).put()
# Membership.get_or_insert(key_name = "%s-%s" % (user.key(), group.key()), user = user, group = group).put()



1 change: 1 addition & 0 deletions buckley/models/post.py
Expand Up @@ -92,6 +92,7 @@ def get_month(month, year):
if not month:
month = datetime.datetime.now().month
if not year:

year = datetime.datetime.now().year

@classmethod
Expand Down
18 changes: 18 additions & 0 deletions buckley/models/test.py
@@ -0,0 +1,18 @@

class Comment(db.Model):
name = db.StringProperty()
email = db.StringProperty()
content = db.TextProperty()
pubdate = db.DateTimeProperty(auto_now_add=True)
views = db.IntegerProperty(default=0)

def get_views(self):
viewcount = self.views
viewcount_cache = memcache.get('test-views-' + self.key().name(), self.key().kind())
if viewcount_cache:
viewcount += viewcount_cache
return viewcount

@classmethod
def flush_views(cls, name):
te
7 changes: 7 additions & 0 deletions buckley/models/user.py
@@ -0,0 +1,7 @@

# todo inherit from built in user property support twitter et al

class User(db.Model):
name = db.StringProperty()
email = db.StringProperty()
author = db.UserProperty()
26 changes: 13 additions & 13 deletions main.py
Expand Up @@ -8,19 +8,19 @@

routes = [

# ('/admin/posts/(.*)/(.*)', controllers.admin.Posts),
# ('/admin/posts/(.*)', controllers.admin.Posts),
# ('/admin/posts', controllers.admin.Posts),
# ('/admin/pages/(.*)/(.*)', controllers.admin.Pages),
# ('/admin/pages/(.*)', controllers.admin.Pages),
# ('/admin/pages', controllers.admin.Pages),
# ('/admin/settings', controllers.admin.Settings),
# ('/admin(.*)', controllers.admin.Settings),
#
# ('/feed(.*)', controllers.Feeds),
# ('/archive(.*)', controllers.Archives),
# ('/projects(.*)', controllers.Projects),
# ('/posts(.*)', controllers.posts.Index),
('/admin/posts/(.*)/(.*)', controllers.admin.Posts),
('/admin/posts/(.*)', controllers.admin.Posts),
('/admin/posts', controllers.admin.Posts),
('/admin/pages/(.*)/(.*)', controllers.admin.Pages),
('/admin/pages/(.*)', controllers.admin.Pages),
('/admin/pages', controllers.admin.Pages),
('/admin/settings', controllers.admin.Settings),
('/admin(.*)', controllers.admin.Settings),
('/feed(.*)', controllers.Feeds),
('/archive(.*)', controllers.Archives),
('/projects(.*)', controllers.Projects),
('/posts(.*)', controllers.posts.Index),
('/(.*)', controllers.posts.Index)
]

Expand Down

0 comments on commit 24a4b95

Please sign in to comment.