-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial Terms of Service support.
- New TermsOfService that represents a ToS, with a name, date, URL and an "active" flag. - New middleware like the existing one for enforcing active emails that requires users which haven't agreed to all "active" ToSes to agree. - Sync support for syncing ToSes to groups, for export to Discourse and Ore. At the moment, this only happens when a user logs in again. - Migration to create the initial SpongePowered 2018-03-10 ToS. - Updated registration form to add checkboxes to agree to the ToSes at registration time. These are all mandatory.
- Loading branch information
Showing
20 changed files
with
372 additions
and
24 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
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
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
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,39 @@ | ||
# Generated by Django 2.0.3 on 2018-04-28 12:14 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0007_group_add_internal_name'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TermsOfService', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=60, unique=True)), | ||
('tos_date', models.DateField()), | ||
('tos_url', models.URLField(unique=True)), | ||
('current_tos', models.BooleanField(default=False)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='TermsOfServiceAcceptance', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('accepted_at', models.DateTimeField(auto_now_add=True)), | ||
('tos', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.TermsOfService')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='user', | ||
name='tos_accepted', | ||
field=models.ManyToManyField(blank=True, related_name='agreed_users', related_query_name='agreed_users', through='accounts.TermsOfServiceAcceptance', to='accounts.TermsOfService', verbose_name='terms of service'), | ||
), | ||
] |
28 changes: 28 additions & 0 deletions
28
spongeauth/accounts/migrations/0009_add_spongepowered_tos_2018-03-10.py
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,28 @@ | ||
# Generated by Django 2.0.3 on 2018-04-28 12:53 | ||
|
||
import datetime | ||
|
||
from django.db import migrations | ||
|
||
|
||
|
||
def create_tos(apps, schema_editor): | ||
TermsOfService = apps.get_model('accounts', 'TermsOfService') | ||
db_alias = schema_editor.connection.alias | ||
tos = TermsOfService( | ||
name='SpongePowered Terms of Service (2018-03-10)', | ||
tos_date=datetime.date(2018, 3, 10), | ||
tos_url='https://docs.spongepowered.org/stable/en/about/tos.html', | ||
current_tos=True) | ||
tos.save(using=db_alias) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0008_auto_20180428_1214'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(create_tos), | ||
] |
40 changes: 40 additions & 0 deletions
40
spongeauth/accounts/migrations/0010_termsofservice_group.py
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,40 @@ | ||
# Generated by Django 2.0.3 on 2018-04-28 15:05 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
def create_group_for_each_tos(apps, schema_editor): | ||
TermsOfService = apps.get_model('accounts', 'TermsOfService') | ||
Group = apps.get_model('accounts', 'Group') | ||
db_alias = schema_editor.connection.alias | ||
for tos in TermsOfService.objects.using(db_alias).all(): | ||
group = Group( | ||
name='Accepted ToS: ' + tos.name, | ||
internal_name='accepted_tos_{}'.format(tos.pk), | ||
internal_only=True) | ||
group.save(using=db_alias) | ||
group.user_set.set(tos.agreed_users.all()) | ||
tos.group = group | ||
tos.save(using=db_alias) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('accounts', '0009_add_spongepowered_tos_2018-03-10'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='termsofservice', | ||
name='group', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='accounts.Group'), | ||
), | ||
migrations.RunPython(create_group_for_each_tos), | ||
migrations.AlterField( | ||
model_name='termsofservice', | ||
name='group', | ||
field=models.ForeignKey(null=False, on_delete=django.db.models.deletion.CASCADE, to='accounts.Group'), | ||
), | ||
] |
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
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
Oops, something went wrong.