Skip to content

Commit

Permalink
feat: Allow TermsOfServiceAllSites to edit existing records.
Browse files Browse the repository at this point in the history
  • Loading branch information
ztraboo authored and fujimeh committed May 30, 2023
1 parent d8ad740 commit df1455f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
5 changes: 4 additions & 1 deletion openedx/features/termsofservice/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ class TermsOfServiceAcknowledgementAdmin(admin.ModelAdmin):
class TermsOfServiceSitesAdmin(admin.ModelAdmin):
list_display = ('site', 'curf')

class TermsOfServiceAllSitesAdmin(admin.ModelAdmin):
list_display = ('curf',)


admin.site.register(TermsOfService, TermsOfServiceAdmin)
admin.site.register(TermsOfServiceAcknowledgement, TermsOfServiceAcknowledgementAdmin)
admin.site.register(TermsOfServiceSites, TermsOfServiceSitesAdmin)
admin.site.register(TermsOfServiceAllSites)
admin.site.register(TermsOfServiceAllSites, TermsOfServiceAllSitesAdmin)
4 changes: 2 additions & 2 deletions openedx/features/termsofservice/api/v1/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# lint-amnesty, pylint: disable=missing-module-docstring

from django.views.decorators.csrf import ensure_csrf_cookie
from django.http import JsonResponse
from django.http import HttpResponse, JsonResponse
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from django.conf import settings
from django.shortcuts import redirect
Expand Down Expand Up @@ -91,4 +91,4 @@ def terms_of_service_api(request): # lint-amnesty, pylint: disable=missing-func
user_TOS_ack = TermsOfServiceAcknowledgement(user_id=request.user.id, curf_id=current_valid_curf_id)
user_TOS_ack.save()

return redirect(request.path_info)
return HttpResponse("Successfully Posted Terms of Service Update", status=200)
17 changes: 9 additions & 8 deletions openedx/features/termsofservice/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.13 on 2023-01-10 17:52
# Generated by Django 3.2.13 on 2023-02-22 22:05

from django.conf import settings
from django.db import migrations, models
Expand All @@ -25,22 +25,23 @@ class Migration(migrations.Migration):
],
),
migrations.CreateModel(
name='TermsOfServiceAllSites',
name='TermsOfServiceSites',
fields=[
('curf', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='termsofservice.termsofservice', to_field='curf_id')),
('site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='sites.site')),
('curf', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='termsofservice.termsofservice', to_field='curf_id')),
],
options={
'verbose_name': 'TermsOfServiceAllSite',
'verbose_name': 'TOS Site',
},
),
migrations.CreateModel(
name='TermsOfServiceSites',
name='TermsOfServiceAllSites',
fields=[
('site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='sites.site')),
('curf', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='termsofservice.termsofservice', to_field='curf_id')),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('curf', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='termsofservice.termsofservice', to_field='curf_id')),
],
options={
'verbose_name': 'TOS Site',
'verbose_name': 'TermsOfServiceAllSite',
},
),
migrations.CreateModel(
Expand Down
6 changes: 5 additions & 1 deletion openedx/features/termsofservice/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ class TermsOfServiceAllSites(models.Model):
class Meta:
app_label = 'termsofservice'
verbose_name = 'TermsOfServiceAllSite'
curf = models.ForeignKey(TermsOfService, primary_key=True, to_field="curf_id", on_delete=models.CASCADE)

# id = models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)
curf = models.OneToOneField(TermsOfService, to_field="curf_id", on_delete=models.CASCADE)

# models.ForeignKey(TermsOfService, primary_key=True, to_field="curf_id", on_delete=models.CASCADE)

0 comments on commit df1455f

Please sign in to comment.