diff --git a/server/crashmanager/forms.py b/server/crashmanager/forms.py index 145ce4fd..3de90a94 100644 --- a/server/crashmanager/forms.py +++ b/server/crashmanager/forms.py @@ -178,31 +178,6 @@ class Meta: class UserSettingsForm(ModelForm): - helper = FormHelper() - helper.layout = Layout( - "defaultToolsFilter", - Row( - Field("defaultProviderId", wrapper_class="col-md-6"), - Field("defaultTemplateId", wrapper_class="col-md-6"), - ), - "email", - HTML("""
Subscribe to notifications:
"""), - "inaccessible_bug", - "coverage_drop", - "bucket_hit", - "tasks_failed", - Submit("submit", "Save settings", css_class="btn btn-danger"), - ) - defaultToolsFilter = ModelMultipleChoiceField( - queryset=Tool.objects.all(), - label="Select the tools you would like to include in your default views:", - widget=CheckboxSelectMultiple(), - required=False, - ) - defaultProviderId = ModelChoiceField( - queryset=BugProvider.objects.all(), label="Default Provider:", empty_label=None - ) - defaultTemplateId = ChoiceField(label="Default Template:") email = EmailField(label="Email:") class Meta: @@ -220,17 +195,6 @@ class Meta: def __init__(self, *args, **kwargs): self.user = kwargs.pop("user", None) super().__init__(*args, **kwargs) - - self.fields["defaultTemplateId"].choices = list( - dict.fromkeys( - [ - (t.pk, f"{p.classname}: {t}") - for p in BugProvider.objects.all() - for t in p.getInstance().getTemplateList() - ] - ) - ) - instance = kwargs.get("instance", None) if instance: self.initial["email"] = instance.user.email @@ -239,8 +203,10 @@ def __init__(self, *args, **kwargs): self.fields["email"].required = False self.fields["email"].widget.attrs["readonly"] = True + self.fields["defaultToolsFilter"].required = False + def clean_defaultToolsFilter(self): - data = self.cleaned_data["defaultToolsFilter"] + data = self.cleaned_data.get("defaultToolsFilter", None) if ( self.user and list(self.user.defaultToolsFilter.all()) != list(data) @@ -252,7 +218,7 @@ def clean_defaultToolsFilter(self): return data def clean_defaultProviderId(self): - data = self.cleaned_data["defaultProviderId"].id + data = self.cleaned_data["defaultProviderId"] return data def save(self, *args, **kwargs): diff --git a/server/crashmanager/templates/usersettings.html b/server/crashmanager/templates/usersettings.html index 1b480fc8..2fee40d4 100644 --- a/server/crashmanager/templates/usersettings.html +++ b/server/crashmanager/templates/usersettings.html @@ -1,5 +1,4 @@ {% extends 'layouts/layout_base.html' %} -{% load crispy_forms_tags %} {% block title %}User Settings{% endblock title %} @@ -8,19 +7,53 @@