Allow add and update domain's record
This commit is contained in:
parent
f26b2f0e87
commit
a6be3e5b00
|
@ -153,3 +153,10 @@ class RecordCreateForm(forms.ModelForm):
|
||||||
if commit:
|
if commit:
|
||||||
super().save(commit=True)
|
super().save(commit=True)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
class RecordUpdateForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Record
|
||||||
|
fields = ("ttl", "type", "value")
|
||||||
|
|
|
@ -22,7 +22,13 @@
|
||||||
{% for record in object.records.all %}
|
{% for record in object.records.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ record.type }}</td>
|
<td>{{ record.type }}</td>
|
||||||
<td>{{ record.value }}</td>
|
<td>
|
||||||
|
<a href="{% url 'musician:domain-update-record' object.pk record.pk %}">
|
||||||
|
{{ record.value }}
|
||||||
|
<i class="ml-3 fas fa-edit"></i></a>
|
||||||
|
<a href="{% url 'musician:domain-delete-record' object.pk record.pk %}">
|
||||||
|
<i class="ml-3 text-danger fas fa-trash"></i></a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends "musician/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<p>{% blocktrans %}Are you sure that you want remove the following record"?{% endblocktrans %}</p>
|
||||||
|
<pre>{{ object.type}} {{ object.value}}</pre>
|
||||||
|
<p class="alert alert-warning"><strong>{% trans 'WARNING: This action cannot be undone.' %}</strong></p>
|
||||||
|
<input class="btn btn-danger" type="submit" value="{% trans 'Delete' %}">
|
||||||
|
<a class="btn btn-secondary" href="{% url 'musician:domain-detail' view.kwargs.pk %}">{% trans 'Cancel' %}</a>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
|
@ -2,7 +2,7 @@
|
||||||
{% load bootstrap4 i18n %}
|
{% load bootstrap4 i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<a class="btn-arrow-left" href="{% url 'musician:domain-detail' form.domain.pk %}">{% trans "Go back" %}</a>
|
<a class="btn-arrow-left" href="{% url 'musician:domain-detail' view.kwargs.pk %}">{% trans "Go back" %}</a>
|
||||||
|
|
||||||
<h1 class="service-name">{% trans "Add record for" %} <span class="font-weight-light">{{ form.domain.name }}</span></h1>
|
<h1 class="service-name">{% trans "Add record for" %} <span class="font-weight-light">{{ form.domain.name }}</span></h1>
|
||||||
|
|
||||||
|
@ -10,11 +10,11 @@
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{% bootstrap_form form %}
|
||||||
{% buttons %}
|
{% buttons %}
|
||||||
<a class="btn btn-light mr-2" href="{% url 'musician:domain-detail' form.domain.pk %}"">{% trans "Cancel" %}</a>
|
<a class="btn btn-light mr-2" href="{% url 'musician:domain-detail' view.kwargs.pk %}"">{% trans "Cancel" %}</a>
|
||||||
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
||||||
{% if form.instance.pk %}
|
{% if form.instance.pk %}
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<a class="btn btn-danger" href="{% url 'musician:domain-record-delete' form.instance.pk %}">{% trans "Delete" %}</a>
|
<a class="btn btn-danger" href="{% url 'musician:domain-delete-record' view.kwargs.pk form.instance.pk %}">{% trans "Delete" %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endbuttons %}
|
{% endbuttons %}
|
||||||
|
|
|
@ -14,8 +14,12 @@ urlpatterns = [
|
||||||
path('auth/login/', views.LoginView.as_view(), name='login'),
|
path('auth/login/', views.LoginView.as_view(), name='login'),
|
||||||
path('auth/logout/', views.LogoutView.as_view(), name='logout'),
|
path('auth/logout/', views.LogoutView.as_view(), name='logout'),
|
||||||
path('dashboard/', views.DashboardView.as_view(), name='dashboard'),
|
path('dashboard/', views.DashboardView.as_view(), name='dashboard'),
|
||||||
|
|
||||||
path('domains/<int:pk>/', views.DomainDetailView.as_view(), name='domain-detail'),
|
path('domains/<int:pk>/', views.DomainDetailView.as_view(), name='domain-detail'),
|
||||||
path('domains/<int:pk>/add-record/', views.DomainAddRecordView.as_view(), name='domain-add-record'),
|
path('domains/<int:pk>/add-record/', views.DomainAddRecordView.as_view(), name='domain-add-record'),
|
||||||
|
path('domains/<int:pk>/records/<int:record_pk>/update/', views.DomainUpdateRecordView.as_view(), name='domain-update-record'),
|
||||||
|
path('domains/<int:pk>/records/<int:record_pk>/delete/', views.DomainDeleteRecordView.as_view(), name='domain-delete-record'),
|
||||||
|
|
||||||
path('billing/', views.BillingView.as_view(), name='billing'),
|
path('billing/', views.BillingView.as_view(), name='billing'),
|
||||||
path('bills/<int:pk>/download/', views.BillDownloadView.as_view(), name='bill-download'),
|
path('bills/<int:pk>/download/', views.BillDownloadView.as_view(), name='bill-download'),
|
||||||
path('profile/', views.ProfileView.as_view(), name='profile'),
|
path('profile/', views.ProfileView.as_view(), name='profile'),
|
||||||
|
|
|
@ -33,7 +33,8 @@ from orchestra.utils.html import html_to_pdf
|
||||||
# from .auth import login as auth_login
|
# from .auth import login as auth_login
|
||||||
from .auth import logout as auth_logout
|
from .auth import logout as auth_logout
|
||||||
from .forms import (LoginForm, MailboxChangePasswordForm, MailboxCreateForm,
|
from .forms import (LoginForm, MailboxChangePasswordForm, MailboxCreateForm,
|
||||||
MailboxUpdateForm, MailForm, RecordCreateForm)
|
MailboxUpdateForm, MailForm, RecordCreateForm,
|
||||||
|
RecordUpdateForm)
|
||||||
from .mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
from .mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
||||||
UserTokenRequiredMixin)
|
UserTokenRequiredMixin)
|
||||||
from .models import Address as AddressService
|
from .models import Address as AddressService
|
||||||
|
@ -483,6 +484,33 @@ class DomainAddRecordView(CustomContextMixin, UserTokenRequiredMixin, CreateView
|
||||||
return reverse_lazy("musician:domain-detail", kwargs={"pk": self.kwargs["pk"]})
|
return reverse_lazy("musician:domain-detail", kwargs={"pk": self.kwargs["pk"]})
|
||||||
|
|
||||||
|
|
||||||
|
class DomainUpdateRecordView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
||||||
|
model = Record
|
||||||
|
form_class = RecordUpdateForm
|
||||||
|
template_name = "musician/record_form.html"
|
||||||
|
pk_url_kwarg = "record_pk"
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
qs = Record.objects.filter(domain__account=self.request.user, domain=self.kwargs["pk"])
|
||||||
|
return qs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("musician:domain-detail", kwargs={"pk": self.kwargs["pk"]})
|
||||||
|
|
||||||
|
|
||||||
|
class DomainDeleteRecordView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
|
||||||
|
model = Record
|
||||||
|
template_name = "musician/record_confirm_delete.html"
|
||||||
|
pk_url_kwarg = "record_pk"
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
qs = Record.objects.filter(domain__account=self.request.user, domain=self.kwargs["pk"])
|
||||||
|
return qs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("musician:domain-detail", kwargs={"pk": self.kwargs["pk"]})
|
||||||
|
|
||||||
|
|
||||||
class LoginView(FormView):
|
class LoginView(FormView):
|
||||||
template_name = 'auth/login.html'
|
template_name = 'auth/login.html'
|
||||||
form_class = LoginForm
|
form_class = LoginForm
|
||||||
|
|
Loading…
Reference in New Issue