Beispiel #1
0
def create_application(identifier, provider_id, name=None,
        owner=None, private=False, version=None, description=None, tags=None,
        uuid=None):
    from core.models import AtmosphereUser
    if not uuid:
        uuid = uuid5(settings.ATMOSPHERE_NAMESPACE_UUID, str(identifier))
        uuid = str(uuid)
    exists = Application.objects.filter(uuid=uuid)
    if exists:
        return exists[0]
    if not name:
        name = "UnknownApp %s" % identifier
    if not description:
        description = "New application - %s" % name
    if not owner:
        owner = _get_admin_owner(provider_id)
    if not tags:
        tags = []
    new_app = Application.objects.create(
            name=name,
            description=description,
            created_by=owner.created_by,
            created_by_identity=owner,
            uuid=uuid)
    if tags:
        updateTags(new_app, tags, owner.created_by)
    return new_app
Beispiel #2
0
def create_application(
        provider_uuid,
        identifier,
        name=None,
        created_by_identity=None,
        created_by=None,
        description=None,
        private=False,
        tags=None,
        uuid=None):
    """
    Create application & Initial ApplicationVersion.
    Build information (Based on MachineRequest or API inputs..)
    and RETURN Application!!
    """
    new_app = None

    if not uuid:
        uuid = _generate_app_uuid(identifier)

    existing_app = Application.objects.filter(uuid=uuid)
    if existing_app.count():
        new_app = existing_app[0]

    if not name:
        name = "Imported App: %s" % identifier
    if not description:
        description = "Imported Application - %s" % name
    if created_by:
        created_by_identity = _username_lookup(
            provider_uuid,
            created_by.username)
    if not created_by_identity:
        created_by_identity = _get_admin_owner(provider_uuid)
    if not tags:
        tags = []
    if new_app:
        new_app.name = name
        new_app.description = description
        new_app.created_by = created_by_identity.created_by
        new_app.created_by_identity = created_by_identity
        new_app.private = private
        new_app.save()
    else:
        new_app = Application.objects.create(
            name=name,
            description=description,
            created_by=created_by_identity.created_by,
            created_by_identity=created_by_identity,
            private=private,
            uuid=uuid)
    if tags:
        updateTags(new_app, tags, created_by_identity.created_by)
    return new_app
def create_application(provider_uuid,
                       identifier,
                       name=None,
                       created_by_identity=None,
                       created_by=None,
                       description=None,
                       private=False,
                       tags=None,
                       uuid=None):
    from core.models import AtmosphereUser
    new_app = None

    if not uuid:
        uuid = _generate_app_uuid(identifier)

    existing_app = Application.objects.filter(uuid=uuid)
    if existing_app.count():
        new_app = existing_app[0]

    if not name:
        name = "Imported App: %s" % identifier
    if not description:
        description = "Imported Application - %s" % name
    if created_by:
        created_by_identity = _username_lookup(provider_uuid,
                                               created_by.username)
    if not created_by_identity:
        created_by_identity = _get_admin_owner(provider_uuid)
    if not tags:
        tags = []
    if new_app:
        new_app.name = name
        new_app.description = description
        new_app.created_by = owner.created_by
        new_app.created_by_identity = owner
        new_app.private = private
        new_app.save()
    else:
        new_app = Application.objects.create(
            name=name,
            description=description,
            created_by=created_by_identity.created_by,
            created_by_identity=created_by_identity,
            private=private,
            uuid=uuid)
    if tags:
        updateTags(new_app, tags, created_by_identity.created_by)
    return new_app
Beispiel #4
0
def create_application(provider_uuid, identifier, name=None,
                       created_by_identity=None, created_by=None, description=None, private=False, tags=None, uuid=None):
    from core.models import AtmosphereUser
    new_app = None

    if not uuid:
        uuid = _generate_app_uuid(identifier)

    existing_app = Application.objects.filter(uuid=uuid)
    if existing_app.count():
        new_app = existing_app[0]

    if not name:
        name = "Imported App: %s" % identifier
    if not description:
        description = "Imported Application - %s" % name
    if created_by:
        created_by_identity = _username_lookup(provider_uuid, created_by.username)
    if not created_by_identity:
        created_by_identity = _get_admin_owner(provider_uuid)
    if not tags:
        tags = []
    if new_app:
        new_app.name = name
        new_app.description = description
        new_app.created_by = owner.created_by
        new_app.created_by_identity = owner
        new_app.private = private
        new_app.save()
    else:
        new_app = Application.objects.create(name=name,
                                         description=description,
                                         created_by=created_by_identity.created_by,
                                         created_by_identity=created_by_identity,
                                         private=private,
                                         uuid=uuid)
    if tags:
        updateTags(new_app, tags, created_by_identity.created_by)
    return new_app