refactor osusers.tasks into fileservertasks and ldaptasks

This commit is contained in:
Jan Dittberner 2015-01-19 21:44:57 +01:00
parent 12b95881ec
commit 5b41d93898
6 changed files with 124 additions and 92 deletions

View file

@ -0,0 +1,4 @@
"""
This module contains :py:mod:`fileservertasks.tasks`.
"""

View file

@ -0,0 +1,94 @@
"""
This module defines task stubs for the tasks implemented in the gvafile Celery
worker.
"""
from __future__ import absolute_import
from celery import shared_task
@shared_task
def setup_file_sftp_userdir(username):
"""
This task creates the home directory for an SFTP user if it does not exist
yet.
:param str username: the user name
:raises Exception: if the SFTP directory of the user cannot be created
:return: the created directory name
:rtype: str
"""
@shared_task
def delete_file_sftp_userdir(username):
"""
This task recursively deletes the home directory of an SFTP user if it
does not exist yet.
:param str username: the user name
:raises Exception: if the SFTP directory of the user cannot be removed
:return: the removed directory name
:rtype: str
"""
@shared_task
def setup_file_mail_userdir(username):
"""
This task creates the mail base directory for a user if it does not exist
yet.
:param str username: the user name
:raises Exception: if the mail base directory for the user cannot be
created
:return: the created directory name
:rtype: str
"""
@shared_task
def delete_file_mail_userdir(username):
"""
This task recursively deletes the mail base directory for a user if it
does not exist yet.
:param str username: the user name
:raises Exception: if the mail base directory of the user cannot be removed
:return: the removed directory name
:rtype: str
"""
@shared_task
def create_file_mailbox(username, mailboxname):
"""
This task creates a new mailbox directory for the given user and mailbox
name.
:param str username: the user name
:param str mailboxname: the mailbox name
:raises GVAFileException: if the mailbox directory cannot be created
:return: the created mailbox directory name
:rtype: str
"""
@shared_task
def delete_file_mailbox(username, mailboxname):
"""
This task deletes the given mailbox of the given user.
:param str username: the user name
:param str mailboxname: the mailbox name
:raises GVAFileException: if the mailbox directory cannot be deleted
:return: the deleted mailbox directory name
:rtype: str
"""

View file

@ -0,0 +1,4 @@
"""
This module contains :py:mod:`ldaptasks.tasks`.
"""

View file

@ -1,6 +1,6 @@
""" """
This module defines task stubs for the tasks implemented on the Celery This module defines task stubs for the tasks implemented in the gvaldap Celery
workers. worker.
""" """
from __future__ import absolute_import from __future__ import absolute_import
@ -115,89 +115,3 @@ def delete_ldap_group(groupname):
:rtype: boolean :rtype: boolean
""" """
@shared_task
def setup_file_sftp_userdir(username):
"""
This task creates the home directory for an SFTP user if it does not exist
yet.
:param str username: the user name
:raises Exception: if the SFTP directory of the user cannot be created
:return: the created directory name
:rtype: str
"""
@shared_task
def delete_file_sftp_userdir(username):
"""
This task recursively deletes the home directory of an SFTP user if it
does not exist yet.
:param str username: the user name
:raises Exception: if the SFTP directory of the user cannot be removed
:return: the removed directory name
:rtype: str
"""
@shared_task
def setup_file_mail_userdir(username):
"""
This task creates the mail base directory for a user if it does not exist
yet.
:param str username: the user name
:raises Exception: if the mail base directory for the user cannot be
created
:return: the created directory name
:rtype: str
"""
@shared_task
def delete_file_mail_userdir(username):
"""
This task recursively deletes the mail base directory for a user if it
does not exist yet.
:param str username: the user name
:raises Exception: if the mail base directory of the user cannot be removed
:return: the removed directory name
:rtype: str
"""
@shared_task
def create_file_mailbox(username, mailboxname):
"""
This task creates a new mailbox directory for the given user and mailbox
name.
:param str username: the user name
:param str mailboxname: the mailbox name
:raises GVAFileException: if the mailbox directory cannot be created
:return: the created mailbox directory name
:rtype: str
"""
@shared_task
def delete_file_mailbox(username, mailboxname):
"""
This task deletes the given mailbox of the given user.
:param str username: the user name
:param str mailboxname: the mailbox name
:raises GVAFileException: if the mailbox directory cannot be deleted
:return: the deleted mailbox directory name
:rtype: str
"""

View file

@ -1,3 +1,9 @@
"""
This module defines the database models for mail handling.
"""
from __future__ import unicode_literals
from django.db import models from django.db import models
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
@ -7,7 +13,11 @@ from model_utils.models import TimeStampedModel
from domains.models import MailDomain from domains.models import MailDomain
from osusers.models import User as OsUser from osusers.models import User as OsUser
from osusers.tasks import create_file_mailbox, delete_file_mailbox
from fileservertasks.tasks import (
create_file_mailbox,
delete_file_mailbox,
)
class ActivateAbleMixin(models.Model): class ActivateAbleMixin(models.Model):
@ -22,6 +32,9 @@ class ActivateAbleMixin(models.Model):
class MailboxManager(models.Manager): class MailboxManager(models.Manager):
"""
This is the default manager class for :py:class:`Mailbox`.
"""
def get_next_mailbox_name(self, osuser): def get_next_mailbox_name(self, osuser):
count = 1 count = 1

View file

@ -22,15 +22,18 @@ from passlib.utils import generate_password
from taskresults.models import TaskResult from taskresults.models import TaskResult
from .tasks import ( from ldaptasks.tasks import (
add_ldap_user_to_group, add_ldap_user_to_group,
create_ldap_group, create_ldap_group,
create_ldap_user, create_ldap_user,
delete_file_mail_userdir,
delete_file_sftp_userdir,
delete_ldap_group, delete_ldap_group,
delete_ldap_user, delete_ldap_user,
remove_ldap_user_from_group, remove_ldap_user_from_group,
)
from fileservertasks.tasks import (
delete_file_mail_userdir,
delete_file_sftp_userdir,
setup_file_mail_userdir, setup_file_mail_userdir,
setup_file_sftp_userdir, setup_file_sftp_userdir,
) )