-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #397
- Loading branch information
Showing
13 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ graph: | |
core \ | ||
courses \ | ||
notifications \ | ||
referrals \ | ||
schools \ | ||
students \ | ||
users \ | ||
|
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Referral | ||
|
||
|
||
@admin.register(Referral) | ||
class ReferralAdmin(admin.ModelAdmin): | ||
list_display = ("id", "referring_user", "status") | ||
list_filter = ("status",) | ||
raw_id_fields = ("referring_user",) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ReferralsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "homeschool.referrals" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Generated by Django 3.2 on 2021-05-27 01:54 | ||
|
||
import django.db.models.deletion | ||
import django.utils.timezone | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Referral", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"created_at", | ||
models.DateField(default=django.utils.timezone.localdate), | ||
), | ||
( | ||
"status", | ||
models.IntegerField( | ||
choices=[(1, "Pending"), (2, "Sent"), (3, "Converted")], | ||
default=1, | ||
), | ||
), | ||
( | ||
"referring_user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="referrals", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
) | ||
] |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.conf import settings | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
|
||
class Referral(models.Model): | ||
"""A referral allows customers to share School Desk with others""" | ||
|
||
class Status(models.IntegerChoices): | ||
PENDING = 1 | ||
SENT = 2 | ||
CONVERTED = 3 | ||
|
||
referring_user = models.ForeignKey( | ||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="referrals" | ||
) | ||
created_at = models.DateField(default=timezone.localdate) | ||
status = models.IntegerField(choices=Status.choices, default=Status.PENDING) |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import factory | ||
|
||
|
||
class ReferralFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = "referrals.Referral" | ||
|
||
referring_user = factory.SubFactory("homeschool.users.tests.factories.UserFactory") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from homeschool.referrals.tests.factories import ReferralFactory | ||
from homeschool.test import TestCase | ||
|
||
|
||
class TestReferral(TestCase): | ||
def test_factory(self): | ||
referral = ReferralFactory() | ||
|
||
assert referral.referring_user is not None | ||
assert referral.created_at is not None | ||
assert referral.status == referral.Status.PENDING |
Empty file.
This file contains 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