Ejemplo n.º 1
0
def site_clone(request):

    l = request.GET['ids'].split(',')
    site_id = [int(i) for i in l][0]
    site = get_object_or_404(Site, pk=site_id)

    default_name = "%s_copy" % (site.short_name, )

    form = Clone(request.POST if request.POST else None,
                 initial={'new_name': default_name})

    if form.is_valid():
        #what sites:

        do_clone = form.cleaned_data['clone']

        ctask = rename.delay(site, form.cleaned_data['new_name'], do_clone)
        event = Event(task_id=ctask.task_id,
                      site=site,
                      user=request.user,
                      event='migrate')
        event.save()
        messages.add_message(
            request, messages.INFO,
            "The clone of the site %s has been queued: %s" %
            (site, ctask.task_id))

        return redirect(urlresolvers.reverse('admin:deploy_site_changelist'))

    data = {
        'user': request.user,
        'form': form,
    }

    return render_to_response('clone.html', data)
Ejemplo n.º 2
0
def site_clone(request):

    l = request.GET["ids"].split(",")
    site_id = [int(i) for i in l][0]
    site = get_object_or_404(Site, pk=site_id)

    default_name = "%s_copy" % (site.short_name,)

    form = Clone(request.POST if request.POST else None, initial={"new_name": default_name})

    if form.is_valid():
        # what sites:

        do_clone = form.cleaned_data["clone"]

        ctask = rename.delay(site, form.cleaned_data["new_name"], do_clone)
        event = Event(task_id=ctask.task_id, site=site, user=request.user, event="migrate")
        event.save()
        messages.add_message(
            request, messages.INFO, "The clone of the site %s has been queued: %s" % (site, ctask.task_id)
        )

        return redirect(urlresolvers.reverse("admin:deploy_site_changelist"))

    data = {"user": request.user, "form": form}

    return render_to_response("clone.html", data)
Ejemplo n.º 3
0
def site_manage(request, sid):
    site = get_object_or_404(Site, pk=sid)
    events = Event.objects.filter(site=site).order_by("date")
    callbacks = Event.objects.filter(site=site, event="status").order_by("date")

    # this is gross and I would really like to be rid of it.
    op = request.POST.get("submit", None)

    form_instance = request.POST if request.method == "POST" else None

    forms = {
        "clone": Clone(form_instance if op == "clone" else None),
        "migrate": Migrate(form_instance if op == "migrate" else None),
        "drush": Drush(form_instance if op == "drush" else None),
    }

    ctask = None

    if not op == None:
        if op == "enable":
            ctask = enable.delay(site)
        elif op == "disable":
            ctask = disable.delay(site)
        elif op == "cache":
            ctask = cacheclear.delay(site)
        elif op == "varnish":
            ctask = varnishclear.delay(site)
        elif op == "verify":
            ctask = verify.delay(site)
        elif op == "migrate":
            if forms["migrate"].is_valid():
                new_platform = Platform.objects.get(pk=forms["migrate"].cleaned_data["new_platform"])
                if new_platform:
                    ctask = migrate.delay(site, new_platform)
        elif op == "clone" or op == "rename":
            if forms["clone"].is_valid():
                new_name = forms["clone"].cleaned_data["new_name"]
                ctask = rename.delay(site, new_name, op == "clone")

        if not ctask == None:
            # record the task as an event, that way it will display in the task log.
            event = Event(task_id=ctask.task_id, site=site, user=request.user, event=op)
            event.save()

            messages.add_message(
                request, messages.INFO, "The %s of the site %s has been queued as '%s'." % (op, site, ctask.task_id)
            )

            return redirect(urlresolvers.reverse("deploy.views.site_manage", args=(sid,)))

    data = {"events": events, "user": request.user, "site": site, "callbacks": callbacks, "forms": forms}

    return render_to_response("site-manage.html", data)
Ejemplo n.º 4
0
def site_manage(request, sid):
    site = get_object_or_404(Site, pk=sid)
    events = Event.objects.filter(site=site).order_by('date')
    callbacks = Event.objects.filter(site=site,
                                     event='status').order_by('date')

    # this is gross and I would really like to be rid of it.
    op = request.POST.get('submit', None)

    form_instance = request.POST if request.method == 'POST' else None

    forms = {
        'clone': Clone(form_instance if op == 'clone' else None),
        'migrate': Migrate(form_instance if op == 'migrate' else None),
        'drush': Drush(form_instance if op == 'drush' else None),
    }

    ctask = None

    if not op == None:
        if op == 'enable':
            ctask = enable.delay(site)
        elif op == 'disable':
            ctask = disable.delay(site)
        elif op == 'cache':
            ctask = cacheclear.delay(site)
        elif op == 'varnish':
            ctask = varnishclear.delay(site)
        elif op == 'verify':
            ctask = verify.delay(site)
        elif op == 'migrate':
            if forms['migrate'].is_valid():
                new_platform = Platform.objects.get(
                    pk=forms['migrate'].cleaned_data['new_platform'])
                if new_platform:
                    ctask = migrate.delay(site, new_platform)
        elif op == 'clone' or op == 'rename':
            if forms['clone'].is_valid():
                new_name = forms['clone'].cleaned_data['new_name']
                ctask = rename.delay(site, new_name, op == 'clone')

        if not ctask == None:
            #record the task as an event, that way it will display in the task log.
            event = Event(task_id=ctask.task_id,
                          site=site,
                          user=request.user,
                          event=op)
            event.save()

            messages.add_message(
                request, messages.INFO,
                "The %s of the site %s has been queued as '%s'." %
                (op, site, ctask.task_id))

            return redirect(
                urlresolvers.reverse('deploy.views.site_manage', args=(sid, )))

    data = {
        'events': events,
        'user': request.user,
        'site': site,
        'callbacks': callbacks,
        'forms': forms
    }

    return render_to_response('site-manage.html', data)