mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +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 LinkDomainForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.LinkDomain
|
model = models.LinkDomain
|
||||||
fields = ["id", "name"]
|
fields = ["name"]
|
||||||
|
|
||||||
|
|
||||||
class FileLinkForm(CustomForm):
|
class FileLinkForm(CustomForm):
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block modal-form-open %}
|
{% 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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block modal-body %}
|
{% block modal-body %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<label class="label" for="id_name">{% trans "Name:" %}</label>
|
<label class="label" for="id_name">{% trans "Name:" %}</label>
|
||||||
<div class="control">
|
<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>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -154,12 +154,12 @@ urlpatterns = [
|
||||||
name="settings-email-blocks-delete",
|
name="settings-email-blocks-delete",
|
||||||
),
|
),
|
||||||
re_path(
|
re_path(
|
||||||
r"^setting/link-domains/(?P<status>(pending|approved|blocked|))/?",
|
r"^setting/link-domains/(?P<status>(pending|approved|blocked))/?$",
|
||||||
views.LinkDomain.as_view(),
|
views.LinkDomain.as_view(),
|
||||||
name="settings-link-domain",
|
name="settings-link-domain",
|
||||||
),
|
),
|
||||||
re_path(
|
re_path(
|
||||||
r"^setting/link-domains/?",
|
r"^setting/link-domains/(?P<status>(pending|approved|blocked))/(?P<domain_id>\d+)/?$",
|
||||||
views.LinkDomain.as_view(),
|
views.LinkDomain.as_view(),
|
||||||
name="settings-link-domain",
|
name="settings-link-domain",
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
""" Manage link domains"""
|
""" Manage link domains"""
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
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.template.response import TemplateResponse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
@ -15,7 +16,7 @@ from bookwyrm import forms, models
|
||||||
class LinkDomain(View):
|
class LinkDomain(View):
|
||||||
"""Moderate links"""
|
"""Moderate links"""
|
||||||
|
|
||||||
def get(self, request, status="pending"):
|
def get(self, request, status):
|
||||||
"""view pending domains"""
|
"""view pending domains"""
|
||||||
data = {
|
data = {
|
||||||
"domains": models.LinkDomain.objects.filter(
|
"domains": models.LinkDomain.objects.filter(
|
||||||
|
@ -28,5 +29,9 @@ class LinkDomain(View):
|
||||||
request, "settings/link_domains/link_domains.html", data
|
request, "settings/link_domains/link_domains.html", data
|
||||||
)
|
)
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request, status, domain_id):
|
||||||
"""post?"""
|
"""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