-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update some fields in customer agreemnet model
- Loading branch information
1 parent
9b54b8d
commit b2ea305
Showing
14 changed files
with
294 additions
and
132 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
69 changes: 69 additions & 0 deletions
69
...ns/migrations/0072_remove_customeragreement_hyper_link_text_for_expired_modal_and_more.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,69 @@ | ||
# Generated by Django 4.2.16 on 2024-10-14 10:58 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('subscriptions', '0071_customeragreement_enable_auto_applied_subscriptions_with_universal_link_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='customeragreement', | ||
name='hyper_link_text_for_expired_modal', | ||
), | ||
migrations.RemoveField( | ||
model_name='customeragreement', | ||
name='url_for_expired_modal', | ||
), | ||
migrations.RemoveField( | ||
model_name='historicalcustomeragreement', | ||
name='hyper_link_text_for_expired_modal', | ||
), | ||
migrations.RemoveField( | ||
model_name='historicalcustomeragreement', | ||
name='url_for_expired_modal', | ||
), | ||
migrations.AddField( | ||
model_name='customeragreement', | ||
name='button_label_in_modal', | ||
field=models.CharField(blank=True, help_text='The text that will appear as on the button in the expiration modal', max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='customeragreement', | ||
name='modal_header_text', | ||
field=models.CharField(blank=True, help_text='The bold text that will appear as the header in the expiration modal.', max_length=512, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='customeragreement', | ||
name='url_for_button_in_modal', | ||
field=models.CharField(blank=True, help_text='The URL that should underly the sole button in the expiration modal', max_length=512, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='historicalcustomeragreement', | ||
name='button_label_in_modal', | ||
field=models.CharField(blank=True, help_text='The text that will appear as on the button in the expiration modal', max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='historicalcustomeragreement', | ||
name='modal_header_text', | ||
field=models.CharField(blank=True, help_text='The bold text that will appear as the header in the expiration modal.', max_length=512, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='historicalcustomeragreement', | ||
name='url_for_button_in_modal', | ||
field=models.CharField(blank=True, help_text='The URL that should underly the sole button in the expiration modal', max_length=512, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='customeragreement', | ||
name='expired_subscription_modal_messaging', | ||
field=models.TextField(blank=True, help_text='The content of a modal that will appear to learners upon subscription expiration. This text can be used for custom guidance per customer.', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalcustomeragreement', | ||
name='expired_subscription_modal_messaging', | ||
field=models.TextField(blank=True, help_text='The content of a modal that will appear to learners upon subscription expiration. This text can be used for custom guidance per customer.', null=True), | ||
), | ||
] |
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,30 @@ | ||
import bleach | ||
|
||
|
||
def sanitize_html(html_content): | ||
""" | ||
Sanitize HTML content to allow only safe tags and attributes, | ||
while disallowing JavaScript and unsafe protocols. | ||
""" | ||
# Define allowed tags and attributes | ||
allowed_tags = bleach.ALLOWED_TAGS # Allow all standard HTML tags | ||
allowed_attrs = {"*": ["className", "class", "style", "id"]} | ||
|
||
# Clean the HTML content | ||
sanitized_content = bleach.clean( | ||
html_content, | ||
tags=allowed_tags, | ||
attributes=allowed_attrs, | ||
strip=True, # Strip disallowed tags completely | ||
protocols=["http", "https"], # Only allow http and https URLs | ||
) | ||
|
||
# Use bleach.linkify to ensure no javascript: links in <a> tags | ||
sanitized_content = bleach.linkify( | ||
sanitized_content, | ||
callbacks=[ | ||
bleach.callbacks.nofollow | ||
], # Apply 'nofollow' to external links for safety | ||
) | ||
|
||
return sanitized_content |
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 |
---|---|---|
|
@@ -40,3 +40,4 @@ rules | |
simplejson | ||
zipp | ||
django-log-request-id | ||
bleach |
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.