Exemplo n.º 1
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)
Exemplo n.º 2
0
 def site_online(self, request, queryset):
     for site in queryset:
         ctask = enable.delay(site)
         event = Event( task_id=ctask.task_id, site=site,  event="online")
         event.save()
         messages.add_message(request, messages.INFO, "%s has been submitted to be removed from maintenance: %s" % ( site, ctask.task_id) )
Exemplo 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)