Skip to content

Commit

Permalink
version up, fixes in managers
Browse files Browse the repository at this point in the history
  • Loading branch information
zhebrak committed May 13, 2015
1 parent 526891a commit 7bd71aa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -5,3 +5,4 @@ include setup.py
recursive-include statsy/static *
recursive-include statsy/templates *
recursive-include statsy/templatetags *
recursive-include statsy/migrations *
2 changes: 2 additions & 0 deletions requirements.txt
@@ -0,0 +1,2 @@
Django>=1.7
jsonfield>=1.0.0
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -3,7 +3,7 @@
from distutils.core import setup


__version__ = '0.1.1'
__version__ = '0.1.2'

short_description = 'Statistics for Django projects'

Expand Down
18 changes: 16 additions & 2 deletions statsy/managers.py
Expand Up @@ -5,6 +5,8 @@
from django.contrib.auth import get_user_model
from django.db import models

import statsy


class StatsyBaseQuerySet(models.QuerySet):
def active(self):
Expand All @@ -21,10 +23,22 @@ class StatsyEventQuerySet(StatsyBaseQuerySet):

class StatsyQuerySet(models.QuerySet):
def by_group(self, group):
return self.select_related('group').filter(group__name=group)
if isinstance(group, str):
group_id = statsy.groups.get(name=group).id

elif isinstance(group, int):
group_id = group

return self.filter(group_id=group_id)

def by_event(self, event):
return self.select_related('event').filter(event__name=event)
if isinstance(event, str):
event_id = statsy.events.get(name=event).id

elif isinstance(event, int):
event_id = event

return self.filter(event_id=event_id)

def by_user(self, user):
if isinstance(user, get_user_model()):
Expand Down

0 comments on commit 7bd71aa

Please sign in to comment.