musician saas nextcloud/WP initial
This commit is contained in:
parent
ecd273bcc3
commit
228ee30d6e
|
@ -7,6 +7,10 @@ from django.forms.widgets import HiddenInput
|
|||
|
||||
from django.contrib.auth.hashers import make_password
|
||||
|
||||
from orchestra.forms.widgets import SpanWidget
|
||||
from orchestra.forms import widgets
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from orchestra.contrib.domains.models import Domain, Record
|
||||
from orchestra.contrib.mailboxes.models import Address, Mailbox
|
||||
from orchestra.contrib.systemusers.models import WebappUsers, SystemUser
|
||||
|
@ -205,15 +209,12 @@ class SystemUsersChangePasswordForm(ChangePasswordForm):
|
|||
fields = ("password",)
|
||||
model = SystemUser
|
||||
|
||||
from orchestra.forms.widgets import SpanWidget
|
||||
from orchestra.forms import widgets
|
||||
from django.utils.safestring import mark_safe
|
||||
from rest_framework import serializers
|
||||
|
||||
class SaasUpdateForm(forms.ModelForm):
|
||||
site_url = forms.CharField(label=_("Site URL"), widget=SpanWidget(), required=False)
|
||||
|
||||
# dos campos para wordpress
|
||||
blog_id = forms.IntegerField(label=("Blog ID"), widget=widgets.SpanWidget, required=False,
|
||||
blog_id = forms.IntegerField(label=("Blog ID"), widget=SpanWidget(), required=False,
|
||||
help_text=_("ID of this blog used by WordPress, the only attribute that doesn't change."))
|
||||
email = forms.EmailField(label=_("Email"),
|
||||
help_text=_("A new user will be created if the above email address is not in the database.<br>"
|
||||
|
@ -232,7 +233,6 @@ class SaasUpdateForm(forms.ModelForm):
|
|||
self.fields['blog_id'].widget.attrs['readonly'] = True
|
||||
self.fields['service'].widget = HiddenInput()
|
||||
self.fields['data'].widget = HiddenInput()
|
||||
self.fields["custom_url"].widget = HiddenInput()
|
||||
|
||||
# asignar valor al field site_url
|
||||
site_domain = self.instance.get_site_domain()
|
||||
|
@ -252,12 +252,16 @@ class SaasUpdateForm(forms.ModelForm):
|
|||
self.fields['data'].required = False
|
||||
|
||||
if self.instance.service == 'nextcloud':
|
||||
self.fields["email"].widget = HiddenInput()
|
||||
self.fields["blog_id"].widget = HiddenInput()
|
||||
self.fields["custom_url"].widget = HiddenInput()
|
||||
self.fields["email"].widget = HiddenInput()
|
||||
self.fields["email"].required = False
|
||||
|
||||
|
||||
if self.instance.service == 'wordpress':
|
||||
self.fields["is_active"].widget = HiddenInput()
|
||||
self.fields["custom_url"].widget.attrs['readonly'] = True
|
||||
|
||||
admin_url = 'http://%s/wp-admin/' % self.instance.get_site_domain()
|
||||
help_text = 'Admin URL: <a href="{0}">{0}</a>'.format(admin_url)
|
||||
self.fields['site_url'].help_text = mark_safe(help_text)
|
||||
|
@ -268,25 +272,6 @@ class SaasUpdateForm(forms.ModelForm):
|
|||
self.fields[field].initial = self.instance.data.get(field, initial)
|
||||
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
data = {}
|
||||
# Update data fields
|
||||
for field in self.declared_fields:
|
||||
try:
|
||||
data[field] = self.cleaned_data[field]
|
||||
except KeyError:
|
||||
data[field] = self.data[field]
|
||||
# Keep old data fields
|
||||
for field, value in self.instance.data.items():
|
||||
if field not in data:
|
||||
try:
|
||||
data[field] = self.cleaned_data[field]
|
||||
except KeyError:
|
||||
data[field] = value
|
||||
self.cleaned_data['data'] = data
|
||||
|
||||
|
||||
class NextcloudChangePasswordForm(ChangePasswordForm):
|
||||
class Meta:
|
||||
fields = ("password",)
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
||||
{% if form.instance.pk %}
|
||||
<div class="float-right">
|
||||
{% if form.instance.service == 'nextcloud' %}
|
||||
<a class="btn btn-outline-warning" href="{% url 'musician:nextcloud-password' form.instance.pk %}"><i class="fas fa-key"></i> {% trans "Change password" %}</a>
|
||||
{% endif %}
|
||||
<a class="btn btn-danger" href="{% url 'musician:saas-delete' view.kwargs.pk %}">{% trans "Delete" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<th scope="col">{% trans "Name" %}</th>
|
||||
<th scope="col">{% trans "Status" %}</th>
|
||||
<th scope="col">{% trans "Service" %}</th>
|
||||
<th scope="col">{% trans "Service info" %}</th>
|
||||
<!-- <th scope="col">{% trans "Service info" %}</th> -->
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -35,15 +35,15 @@
|
|||
<span class="sr-only">{{ saas.is_active|yesno }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-link" href="{{ saas.manager_url }}" target="_blank" rel="noopener noreferrer" title="{% trans 'Open service admin panel' %}">
|
||||
<a class="btn btn-sm btn-link" href="https://{{ saas.get_site_domain|default:'#' }}" target="_blank" rel="noopener noreferrer" title="{% trans 'Open service admin panel' %}">
|
||||
<i class="fab fa-{{ saas.service }}"></i> {{ saas.service|capfirst }}
|
||||
<span class="sr-only">{% trans "Open service admin panel" %}</span> <i class="fas fa-external-link-alt"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<!-- <td>
|
||||
{% for key, value in saas.data.items %}
|
||||
<label>{{ key }}:</label> <strong>{{ value }}</strong><br/>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</td> -->
|
||||
<td class="text-right">
|
||||
<a class="btn btn-outline-warning" role="button" href="{% url 'musician:saas-update' saas.id %}">
|
||||
<i class="fas fa-tools"></i></a>
|
||||
|
@ -66,5 +66,5 @@
|
|||
{% include "musician/components/table_paginator.html" %}
|
||||
</table>
|
||||
</div>
|
||||
<a class="btn btn-primary mt-4 mb-4" href="#">{% trans "New SaaS" %}</a>
|
||||
<!-- <a class="btn btn-primary mt-4 mb-4" href="#">{% trans "New SaaS" %}</a> -->
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue