Fixed apache backend bug

This commit is contained in:
Marc Aymerich 2014-11-10 16:25:45 +00:00
parent 42c696c6ec
commit 813cfb6f65
2 changed files with 11 additions and 5 deletions

View file

@ -11,6 +11,12 @@ from .services import SoftwareService
class SaaS(models.Model): class SaaS(models.Model):
service = models.CharField(_("service"), max_length=32, service = models.CharField(_("service"), max_length=32,
choices=SoftwareService.get_plugin_choices()) choices=SoftwareService.get_plugin_choices())
# TODO use model username password instead of data
# username = models.CharField(_("username"), max_length=64, unique=True,
# help_text=_("Required. 64 characters or fewer. Letters, digits and ./-/_ only."),
# validators=[validators.RegexValidator(r'^[\w.-]+$',
# _("Enter a valid username."), 'invalid')])
# password = models.CharField(_("password"), max_length=128)
account = models.ForeignKey('accounts.Account', verbose_name=_("account"), account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
related_name='saas') related_name='saas')
data = JSONField(_("data")) data = JSONField(_("data"))

View file

@ -169,15 +169,15 @@ class Apache2Backend(ServiceController):
"else UPDATED=0; fi" % context) "else UPDATED=0; fi" % context)
def get_username(self, site): def get_username(self, site):
option = site.options.filter('user_group') option = site.options.filter(name='user_group').first()
if option: if option:
return option[0].split()[0] return option.value.split()[0]
return site.account.username return site.account.username
def get_groupname(self, site): def get_groupname(self, site):
option = site.options.filter('user_group') option = site.options.filter(name='user_group').first()
if option and ' ' in option: if option and ' ' in option.value:
user, group = option.split() user, group = option.value.split()
return group return group
return site.account.username return site.account.username