Skip to content

Commit

Permalink
Merge branch 'master' into django-v2-circleci
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamu committed Nov 7, 2017
2 parents d4663fa + 04c74b9 commit d624921
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pinax/invitations/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Migration(migrations.Migration):
('invites_sent', models.IntegerField(default=0)),
('invites_allocated', models.IntegerField(default=0)),
('invites_accepted', models.IntegerField(default=0)),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
},
Expand All @@ -34,9 +34,9 @@ class Migration(migrations.Migration):
('message', models.TextField(null=True)),
('sent', models.DateTimeField(default=django.utils.timezone.now)),
('status', models.IntegerField(choices=[(1, b'Sent'), (2, b'Accepted'), (3, b'Joined Independently')])),
('from_user', models.ForeignKey(related_name='invites_sent', to=settings.AUTH_USER_MODEL)),
('signup_code', models.OneToOneField(to='account.SignupCode')),
('to_user', models.ForeignKey(related_name='invites_received', to=settings.AUTH_USER_MODEL, null=True)),
('from_user', models.ForeignKey(related_name='invites_sent', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('signup_code', models.OneToOneField(to='account.SignupCode', on_delete=models.CASCADE)),
('to_user', models.ForeignKey(related_name='invites_received', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True)),
],
options={
},
Expand Down
11 changes: 8 additions & 3 deletions pinax/invitations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ class JoinInvitation(models.Model):
(STATUS_JOINED_INDEPENDENTLY, "Joined Independently")
]

from_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="invites_sent")
from_user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="invites_sent",
)
to_user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
null=True,
related_name="invites_received"
)
message = models.TextField(null=True)
sent = models.DateTimeField(default=timezone.now)
status = models.IntegerField(choices=INVITE_STATUS_CHOICES)
signup_code = models.OneToOneField(SignupCode)
signup_code = models.OneToOneField(SignupCode, on_delete=models.CASCADE)

def to_user_email(self):
return self.signup_code.email
Expand Down Expand Up @@ -91,7 +96,7 @@ def send_invite(*args, **kwargs):

class InvitationStat(models.Model):

user = models.OneToOneField(settings.AUTH_USER_MODEL)
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
invites_sent = models.IntegerField(default=0)
invites_allocated = models.IntegerField(
default=settings.PINAX_INVITATIONS_DEFAULT_INVITE_ALLOCATION
Expand Down
2 changes: 2 additions & 0 deletions pinax/invitations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
TopOffUserView
)

app_name = "pinax_invitations"

urlpatterns = [
url(r"^invite/$", InviteView.as_view(), name="invite"),
url(r"^invite-stat/(?P<pk>\d+)/$", InviteStatView.as_view(), name="invite_stat"),
Expand Down

0 comments on commit d624921

Please sign in to comment.