This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def some_func(): | |
organization = Organization.objects.get(id=1) | |
action_qs = organization.actions.filter(action='fund').by_month() | |
return action_qs | |
def test(): | |
organization_mock = mocker.Mock() | |
patch(..., organization_mock) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Goal(models.Model): | |
def __init__(self): | |
organization | |
recurring_until (datestamp) | |
resets ('monthly', 'yearly') | |
action_type ('fund', 'influence', 'beta') | |
goal (float) | |
def progress(self): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Badge(object): | |
def is_within_limit(): | |
pass | |
class SingleActionSingleCompletionBadgeMixin(): | |
def has_earned(action_obj): | |
pass | |
class FirstAboardBadge(SingleActionCompletionBadgeMixin, Badge): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionType(object): | |
def __init__(self, handle, human, points, notification): | |
self.handle = handle | |
self.human = human | |
self.points = points | |
# expects a string template to be formatted | |
self.notification = notification | |
def is_influence(self): | |
return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table "public.impact_badge" | |
Column | Type | Modifiers | |
-----------------+--------------------------+----------------------------------------------------------- | |
id | integer | not null default nextval('impact_badge_id_seq'::regclass) | |
label | character varying(100) | not null | |
description | text | not null | |
action | character varying(25) | not null | |
required_amount | double precision | not null | |
active | boolean | not null | |
organization_id | integer | not null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### users/models.py | |
class Message(models.Model): | |
user = ForeignKeyField() | |
# we could add a priorty or level field if we want, but lets not do that until we know we need it | |
app_name = CharField(default='users') # i.e. 'impact' | |
template = CharField(default='message.html') # i.e. 'badge_message.html' | |
heading = CharField() | |
content = TextField() | |
action = HStoreField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Message (models.Model): | |
title = models.CharField() | |
body = models.CharField() | |
image = models.HStoreField({'filename': 'filename val', 'alt': 'alt val'}) | |
action = models.HStoreField({'id': 'id_val', 'label': 'label val'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
def mock_user_fixtures(): | |
u1 = UserFactory() | |
u2 = UserFactory() | |
return (u1, u2,) | |
@pytest.fixture | |
def mock_organization_fixtures(): | |
o1 = OrganizationFactory() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BadgeQuerySet(models.QuerySet): | |
def earned_during_month(self, month, year): | |
first = get_first_date_of_month(month, year) | |
last = get_last_date_of_month(month, year) | |
return self.filter(users__created__gte=first, users__created__lte=last) | |
def earned_during_current_month(self): | |
today = get_todays_date() | |
return self.earned_during_month(today.month, today.year) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# APP CONFIGURATION | |
# ------------------------------------------------------------------------------ | |
DJANGO_APPS = [ | |
# Default Django apps: | |
'django.contrib.auth', | |
'django.contrib.sites', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', |