mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-28 18:21:00 +00:00
Added admin notes field to domains (#530)
This commit is contained in:
parent
5ea3d5d143
commit
85b4910829
7 changed files with 56 additions and 0 deletions
|
@ -30,6 +30,10 @@
|
||||||
{% include "forms/_field.html" with field=form.default %}
|
{% include "forms/_field.html" with field=form.default %}
|
||||||
{% include "forms/_field.html" with field=form.users %}
|
{% include "forms/_field.html" with field=form.users %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Admin Notes</legend>
|
||||||
|
{% include "forms/_field.html" with field=form.notes %}
|
||||||
|
</fieldset>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="{% url "admin_domains" %}" class="button secondary left">Back</a>
|
<a href="{% url "admin_domains" %}" class="button secondary left">Back</a>
|
||||||
<button>Create</button>
|
<button>Create</button>
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
{% include "forms/_field.html" with field=form.default %}
|
{% include "forms/_field.html" with field=form.default %}
|
||||||
{% include "forms/_field.html" with field=form.users %}
|
{% include "forms/_field.html" with field=form.users %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Admin Notes</legend>
|
||||||
|
{% include "forms/_field.html" with field=form.notes %}
|
||||||
|
</fieldset>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="{{ domain.urls.root }}" class="button secondary left">Back</a>
|
<a href="{{ domain.urls.root }}" class="button secondary left">Back</a>
|
||||||
<a href="{{ domain.urls.delete }}" class="button delete">Delete</a>
|
<a href="{{ domain.urls.delete }}" class="button delete">Delete</a>
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
<legend>Federation Controls</legend>
|
<legend>Federation Controls</legend>
|
||||||
{% include "forms/_field.html" with field=form.blocked %}
|
{% include "forms/_field.html" with field=form.blocked %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Admin Notes</legend>
|
||||||
|
{% include "forms/_field.html" with field=form.notes %}
|
||||||
|
</fieldset>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="{{ domain.urls.root_federation }}" class="button secondary left">Back</a>
|
<a href="{{ domain.urls.root_federation }}" class="button secondary left">Back</a>
|
||||||
<a href="{{ domain.urls.delete }}" class="button delete">Delete</a>
|
<a href="{{ domain.urls.delete }}" class="button delete">Delete</a>
|
||||||
|
|
18
users/migrations/0014_domain_notes.py
Normal file
18
users/migrations/0014_domain_notes.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 4.1.7 on 2023-03-06 21:26
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("users", "0013_stator_indexes"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="domain",
|
||||||
|
name="notes",
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -92,6 +92,9 @@ class Domain(StatorModel):
|
||||||
# This should be display domains ONLY
|
# This should be display domains ONLY
|
||||||
users = models.ManyToManyField("users.User", related_name="domains", blank=True)
|
users = models.ManyToManyField("users.User", related_name="domains", blank=True)
|
||||||
|
|
||||||
|
# Free-form notes field for admins
|
||||||
|
notes = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
updated = models.DateTimeField(auto_now=True)
|
updated = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,15 @@ class DomainCreate(FormView):
|
||||||
widget=forms.Textarea,
|
widget=forms.Textarea,
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
|
notes = forms.CharField(
|
||||||
|
label="Notes",
|
||||||
|
widget=forms.Textarea(
|
||||||
|
attrs={
|
||||||
|
"rows": 3,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
def clean_domain(self):
|
def clean_domain(self):
|
||||||
if Domain.objects.filter(
|
if Domain.objects.filter(
|
||||||
|
@ -131,6 +140,7 @@ class DomainCreate(FormView):
|
||||||
domain = Domain.objects.create(
|
domain = Domain.objects.create(
|
||||||
domain=form.cleaned_data["domain"],
|
domain=form.cleaned_data["domain"],
|
||||||
service_domain=form.cleaned_data["service_domain"] or None,
|
service_domain=form.cleaned_data["service_domain"] or None,
|
||||||
|
notes=form.cleaned_data["notes"] or None,
|
||||||
public=form.cleaned_data["public"],
|
public=form.cleaned_data["public"],
|
||||||
default=form.cleaned_data["default"],
|
default=form.cleaned_data["default"],
|
||||||
local=True,
|
local=True,
|
||||||
|
@ -173,6 +183,7 @@ class DomainEdit(FormView):
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
self.domain.public = form.cleaned_data["public"]
|
self.domain.public = form.cleaned_data["public"]
|
||||||
self.domain.default = form.cleaned_data["default"]
|
self.domain.default = form.cleaned_data["default"]
|
||||||
|
self.domain.notes = form.cleaned_data["notes"] or None
|
||||||
self.domain.save()
|
self.domain.save()
|
||||||
self.domain.users.set(form.cleaned_data["users"])
|
self.domain.users.set(form.cleaned_data["users"])
|
||||||
if self.domain.default:
|
if self.domain.default:
|
||||||
|
@ -183,6 +194,7 @@ class DomainEdit(FormView):
|
||||||
return {
|
return {
|
||||||
"domain": self.domain.domain,
|
"domain": self.domain.domain,
|
||||||
"service_domain": self.domain.service_domain,
|
"service_domain": self.domain.service_domain,
|
||||||
|
"notes": self.domain.notes,
|
||||||
"public": self.domain.public,
|
"public": self.domain.public,
|
||||||
"default": self.domain.default,
|
"default": self.domain.default,
|
||||||
"users": "\n".join(sorted(user.email for user in self.domain.users.all())),
|
"users": "\n".join(sorted(user.email for user in self.domain.users.all())),
|
||||||
|
|
|
@ -45,6 +45,15 @@ class FederationEdit(FormView):
|
||||||
widget=forms.Select(choices=[(True, "Blocked"), (False, "Not Blocked")]),
|
widget=forms.Select(choices=[(True, "Blocked"), (False, "Not Blocked")]),
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
|
notes = forms.CharField(
|
||||||
|
label="Notes",
|
||||||
|
widget=forms.Textarea(
|
||||||
|
attrs={
|
||||||
|
"rows": 3,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
def dispatch(self, request, domain):
|
def dispatch(self, request, domain):
|
||||||
self.domain = get_object_or_404(
|
self.domain = get_object_or_404(
|
||||||
|
@ -59,10 +68,12 @@ class FederationEdit(FormView):
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
self.domain.blocked = form.cleaned_data["blocked"]
|
self.domain.blocked = form.cleaned_data["blocked"]
|
||||||
|
self.domain.notes = form.cleaned_data["notes"] or None
|
||||||
self.domain.save()
|
self.domain.save()
|
||||||
return redirect(Domain.urls.root_federation)
|
return redirect(Domain.urls.root_federation)
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
return {
|
return {
|
||||||
"blocked": self.domain.blocked,
|
"blocked": self.domain.blocked,
|
||||||
|
"notes": self.domain.notes,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue