738 if not acc: |
738 if not acc: |
739 raise VMMError(_(u"The account '%s' does not exist.") % |
739 raise VMMError(_(u"The account '%s' does not exist.") % |
740 acc.address, NO_SUCH_ACCOUNT) |
740 acc.address, NO_SUCH_ACCOUNT) |
741 acc.update_transport(Transport(self._dbh, transport=transport)) |
741 acc.update_transport(Transport(self._dbh, transport=transport)) |
742 |
742 |
743 def user_disable(self, emailaddress, services=None): |
743 def user_services(self, emailaddress, *services): |
744 """Wrapper for Account.disable(*services)""" |
744 """Wrapper around Account.update_serviceset().""" |
745 if services is None: |
745 kwargs = dict.fromkeys(SERVICES, False) |
746 services = [] |
746 for service in set(services): |
747 else: |
747 if service not in SERVICES: |
748 assert isinstance(services, list) |
748 raise VMMError(_(u"Unknown service: '%s'") % service, |
|
749 UNKNOWN_SERVICE) |
|
750 kwargs[service] = True |
749 acc = self._get_account(emailaddress) |
751 acc = self._get_account(emailaddress) |
750 if not acc: |
752 if not acc: |
751 raise VMMError(_(u"The account '%s' does not exist.") % |
753 raise VMMError(_(u"The account '%s' does not exist.") % |
752 acc.address, NO_SUCH_ACCOUNT) |
754 acc.address, NO_SUCH_ACCOUNT) |
753 acc.disable(*services) |
755 serviceset = ServiceSet(self._dbh, **kwargs) |
754 |
756 acc.update_serviceset(serviceset) |
755 def user_enable(self, emailaddress, services=None): |
|
756 """Wrapper for Account.enable(*services)""" |
|
757 if services is None: |
|
758 services = [] |
|
759 else: |
|
760 assert isinstance(services, list) |
|
761 acc = self._get_account(emailaddress) |
|
762 if not acc: |
|
763 raise VMMError(_(u"The account '%s' does not exist.") % |
|
764 acc.address, NO_SUCH_ACCOUNT) |
|
765 acc.enable(*services) |
|
766 |
757 |
767 def relocated_add(self, emailaddress, targetaddress): |
758 def relocated_add(self, emailaddress, targetaddress): |
768 """Creates a new `Relocated` entry in the database. If there is |
759 """Creates a new `Relocated` entry in the database. If there is |
769 already a relocated user with the given *emailaddress*, only the |
760 already a relocated user with the given *emailaddress*, only the |
770 *targetaddress* for the relocated user will be updated.""" |
761 *targetaddress* for the relocated user will be updated.""" |