mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Functionality to edit name
This commit is contained in:
parent
f580a51f24
commit
3f280af715
4 changed files with 13 additions and 8 deletions
|
@ -219,7 +219,7 @@ class CoverForm(CustomForm):
|
|||
class LinkDomainForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.LinkDomain
|
||||
fields = ["id", "name"]
|
||||
fields = ["name"]
|
||||
|
||||
|
||||
class FileLinkForm(CustomForm):
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block modal-form-open %}
|
||||
<form name="edit-domain-{{ domain.id }}" method="post" action="{% url 'settings-link-domain' %}">
|
||||
<form name="edit-domain-{{ domain.id }}" method="post" action="{% url 'settings-link-domain' status=status domain_id=domain.id %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
{% csrf_token %}
|
||||
<label class="label" for="id_name">{% trans "Name:" %}</label>
|
||||
<div class="control">
|
||||
<input type="text" id="id_name" class="input" value="{{ domain.name }}">
|
||||
<input type="text" id="id_name" class="input" name="name" value="{{ domain.name }}">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -154,12 +154,12 @@ urlpatterns = [
|
|||
name="settings-email-blocks-delete",
|
||||
),
|
||||
re_path(
|
||||
r"^setting/link-domains/(?P<status>(pending|approved|blocked|))/?",
|
||||
r"^setting/link-domains/(?P<status>(pending|approved|blocked))/?$",
|
||||
views.LinkDomain.as_view(),
|
||||
name="settings-link-domain",
|
||||
),
|
||||
re_path(
|
||||
r"^setting/link-domains/?",
|
||||
r"^setting/link-domains/(?P<status>(pending|approved|blocked))/(?P<domain_id>\d+)/?$",
|
||||
views.LinkDomain.as_view(),
|
||||
name="settings-link-domain",
|
||||
),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
""" Manage link domains"""
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
@ -15,7 +16,7 @@ from bookwyrm import forms, models
|
|||
class LinkDomain(View):
|
||||
"""Moderate links"""
|
||||
|
||||
def get(self, request, status="pending"):
|
||||
def get(self, request, status):
|
||||
"""view pending domains"""
|
||||
data = {
|
||||
"domains": models.LinkDomain.objects.filter(
|
||||
|
@ -28,5 +29,9 @@ class LinkDomain(View):
|
|||
request, "settings/link_domains/link_domains.html", data
|
||||
)
|
||||
|
||||
def post(self, request):
|
||||
"""post?"""
|
||||
def post(self, request, status, domain_id):
|
||||
"""Set display name"""
|
||||
domain = get_object_or_404(models.LinkDomain, id=domain_id)
|
||||
form = forms.LinkDomainForm(request.POST, instance=domain)
|
||||
form.save()
|
||||
return redirect('settings-link-domain', status=status)
|
||||
|
|
Loading…
Reference in a new issue