2015-03-23 15:36:51 +00:00
|
|
|
from django import forms
|
2015-09-21 10:28:49 +00:00
|
|
|
from django.utils.safestring import mark_safe
|
2015-03-23 15:36:51 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
2015-09-21 10:28:49 +00:00
|
|
|
from .options import SoftwareService
|
2015-09-29 12:35:22 +00:00
|
|
|
from .. import settings
|
2015-09-21 10:28:49 +00:00
|
|
|
from ..forms import SaaSBaseForm
|
2015-03-23 15:36:51 +00:00
|
|
|
|
|
|
|
|
2015-09-21 10:28:49 +00:00
|
|
|
class WordPressForm(SaaSBaseForm):
|
|
|
|
email = forms.EmailField(label=_("Email"), widget=forms.TextInput(attrs={'size':'40'}),
|
|
|
|
help_text=_("A new user will be created if the above email address is not in the database.<br>"
|
|
|
|
"The username and password will be mailed to this email address."))
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(WordPressForm, self).__init__(*args, **kwargs)
|
|
|
|
if self.is_change:
|
|
|
|
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)
|
2015-03-23 15:36:51 +00:00
|
|
|
|
2015-09-21 13:57:15 +00:00
|
|
|
|
2015-03-23 15:36:51 +00:00
|
|
|
class WordPressDataSerializer(serializers.Serializer):
|
|
|
|
email = serializers.EmailField(label=_("Email"))
|
|
|
|
|
|
|
|
|
|
|
|
class WordPressService(SoftwareService):
|
2015-06-09 11:16:36 +00:00
|
|
|
name = 'wordpress'
|
2015-03-23 15:36:51 +00:00
|
|
|
verbose_name = "WordPress"
|
|
|
|
form = WordPressForm
|
|
|
|
serializer = WordPressDataSerializer
|
|
|
|
icon = 'orchestra/icons/apps/WordPress.png'
|
|
|
|
change_readonly_fileds = ('email',)
|
2015-09-29 12:35:22 +00:00
|
|
|
site_domain = settings.SAAS_WORDPRESS_DOMAIN
|
2015-10-01 16:02:26 +00:00
|
|
|
allow_custom_url = settings.SAAS_WORDPRESS_ALLOW_CUSTOM_URL
|