Compare commits
No commits in common. "a6be3e5b00cdb61e62c4389e606b736ab7a05935" and "7c85f219d80c65d51e41a5e14af374a4b01d2b1e" have entirely different histories.
a6be3e5b00
...
7c85f219d8
|
@ -3,7 +3,7 @@ from django.contrib.auth.forms import AuthenticationForm
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from orchestra.contrib.domains.models import Domain, Record
|
from orchestra.contrib.domains.models import Domain
|
||||||
from orchestra.contrib.mailboxes.models import Address, Mailbox
|
from orchestra.contrib.mailboxes.models import Address, Mailbox
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
|
@ -131,32 +131,6 @@ class MailboxCreateForm(forms.ModelForm):
|
||||||
|
|
||||||
class MailboxUpdateForm(forms.ModelForm):
|
class MailboxUpdateForm(forms.ModelForm):
|
||||||
addresses = forms.MultipleChoiceField(required=False)
|
addresses = forms.MultipleChoiceField(required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = ('addresses',)
|
fields = ('addresses',)
|
||||||
model = Mailbox
|
model = Mailbox
|
||||||
|
|
||||||
|
|
||||||
class RecordCreateForm(forms.ModelForm):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Record
|
|
||||||
fields = ("ttl", "type", "value")
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.domain = kwargs.pop('domain')
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def save(self, commit=True):
|
|
||||||
instance = super().save(commit=False)
|
|
||||||
instance.domain = self.domain
|
|
||||||
if commit:
|
|
||||||
super().save(commit=True)
|
|
||||||
return instance
|
|
||||||
|
|
||||||
|
|
||||||
class RecordUpdateForm(forms.ModelForm):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Record
|
|
||||||
fields = ("ttl", "type", "value")
|
|
||||||
|
|
|
@ -22,16 +22,9 @@
|
||||||
{% for record in object.records.all %}
|
{% for record in object.records.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ record.type }}</td>
|
<td>{{ record.type }}</td>
|
||||||
<td>
|
<td>{{ record.value }}</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>
|
||||||
</table>
|
</table>
|
||||||
<a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:domain-add-record' object.pk %}">{% trans "Add new record" %}</a></td>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{% 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 %}
|
|
|
@ -1,22 +0,0 @@
|
||||||
{% extends "musician/base.html" %}
|
|
||||||
{% load bootstrap4 i18n %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% bootstrap_form form %}
|
|
||||||
{% buttons %}
|
|
||||||
<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>
|
|
||||||
{% if form.instance.pk %}
|
|
||||||
<div class="float-right">
|
|
||||||
<a class="btn btn-danger" href="{% url 'musician:domain-delete-record' view.kwargs.pk form.instance.pk %}">{% trans "Delete" %}</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endbuttons %}
|
|
||||||
</form>
|
|
||||||
{% endblock %}
|
|
|
@ -8,18 +8,14 @@ from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
|
||||||
app_name = 'musician'
|
app_name = 'musician'
|
||||||
|
|
||||||
urlpatterns = [
|
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>/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'),
|
||||||
|
|
|
@ -24,7 +24,7 @@ from requests.exceptions import HTTPError
|
||||||
from orchestra import get_version
|
from orchestra import get_version
|
||||||
from orchestra.contrib.bills.models import Bill
|
from orchestra.contrib.bills.models import Bill
|
||||||
from orchestra.contrib.databases.models import Database
|
from orchestra.contrib.databases.models import Database
|
||||||
from orchestra.contrib.domains.models import Domain, Record
|
from orchestra.contrib.domains.models import Domain
|
||||||
from orchestra.contrib.lists.models import List
|
from orchestra.contrib.lists.models import List
|
||||||
from orchestra.contrib.mailboxes.models import Address, Mailbox
|
from orchestra.contrib.mailboxes.models import Address, Mailbox
|
||||||
from orchestra.contrib.saas.models import SaaS
|
from orchestra.contrib.saas.models import SaaS
|
||||||
|
@ -33,8 +33,7 @@ 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)
|
||||||
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
|
||||||
|
@ -469,48 +468,6 @@ class DomainDetailView(CustomContextMixin, UserTokenRequiredMixin, DetailView):
|
||||||
return Domain.objects.filter(account=self.request.user)
|
return Domain.objects.filter(account=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
class DomainAddRecordView(CustomContextMixin, UserTokenRequiredMixin, CreateView):
|
|
||||||
model = Record
|
|
||||||
form_class = RecordCreateForm
|
|
||||||
template_name = "musician/record_form.html"
|
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
|
||||||
kwargs = super().get_form_kwargs()
|
|
||||||
domain = get_object_or_404(Domain, account=self.request.user, pk=self.kwargs["pk"])
|
|
||||||
kwargs['domain'] = domain
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
def get_success_url(self):
|
|
||||||
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