Skip to content

Commit

Permalink
Admin: remove temporal opt-out email settings (#11164)
Browse files Browse the repository at this point in the history
* Admin: remove temporal opt-out email settings

Closes #11163

* Remove leftovers

* Just "Save"
  • Loading branch information
humitos committed Feb 28, 2024
1 parent 90e2d48 commit b03f28d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
26 changes: 1 addition & 25 deletions readthedocs/core/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Forms for core app."""

import structlog
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, Layout, Submit
from django import forms
from django.contrib.auth.models import User
from django.core.exceptions import NON_FIELD_ERRORS
Expand All @@ -23,15 +21,7 @@ class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
# Don't allow users edit someone else's user page
profile_fields = ["first_name", "last_name", "homepage"]
optout_email_fields = [
"optout_email_config_file_deprecation",
"optout_email_build_image_deprecation",
]
fields = (
*profile_fields,
*optout_email_fields,
)
fields = ["first_name", "last_name", "homepage"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -41,20 +31,6 @@ def __init__(self, *args, **kwargs):
except AttributeError:
pass

self.helper = FormHelper()
field_sets = [
Fieldset(
_("User settings"),
*self.Meta.profile_fields,
),
Fieldset(
_("Email settings"),
*self.Meta.optout_email_fields,
),
]
self.helper.layout = Layout(*field_sets)
self.helper.add_input(Submit("save", _("Save")))

def save(self, commit=True):
first_name = self.cleaned_data.pop("first_name", None)
last_name = self.cleaned_data.pop("last_name", None)
Expand Down
31 changes: 31 additions & 0 deletions readthedocs/core/migrations/0015_remove_email_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.10 on 2024-02-27 18:55

from django.db import migrations
from django_safemigrate import Safe


class Migration(migrations.Migration):
safe = Safe.after_deploy

dependencies = [
("core", "0014_optout_email_build_image_deprecation"),
]

operations = [
migrations.RemoveField(
model_name="historicaluserprofile",
name="optout_email_build_image_deprecation",
),
migrations.RemoveField(
model_name="historicaluserprofile",
name="optout_email_config_file_deprecation",
),
migrations.RemoveField(
model_name="userprofile",
name="optout_email_build_image_deprecation",
),
migrations.RemoveField(
model_name="userprofile",
name="optout_email_config_file_deprecation",
),
]
16 changes: 0 additions & 16 deletions readthedocs/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ class UserProfile(TimeStampedModel):
whitelisted = models.BooleanField(_("Whitelisted"), default=False)
banned = models.BooleanField(_("Banned"), default=False)

# Opt-out on emails
# NOTE: this is a temporary field that we can remove after September 25, 2023
# See https://blog.readthedocs.com/migrate-configuration-v2/
optout_email_config_file_deprecation = models.BooleanField(
_("Opt-out from email about 'Config file deprecation'"),
default=False,
null=True,
)
# NOTE: this is a temporary field that we can remove after October 16, 2023
# See https://blog.readthedocs.com/use-build-os-config/
optout_email_build_image_deprecation = models.BooleanField(
_("Opt-out from email about '\"build.image\" config key deprecation'"),
default=False,
null=True,
)

# Model history
history = ExtraHistoricalRecords()

Expand Down
6 changes: 4 additions & 2 deletions readthedocs/templates/profiles/private/edit_profile.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "profiles/base_profile_edit.html" %}
{% load crispy_forms_tags %}

{% load i18n %}

Expand All @@ -10,5 +9,8 @@
{% block edit_content_header %} {% trans "Edit your profile" %} {% endblock %}

{% block edit_content %}
{% crispy form %}
<form method="POST" action=".">{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="{% trans "Save" %}" id="submit"/>
</form>
{% endblock %}

0 comments on commit b03f28d

Please sign in to comment.