Example #1
0
def Delete_Object(request, object_class):
    """
    Process form to delete an object.
    if the object exists and user is registered,
    deletes object from database.
    """
    if request.method == "POST":
        ## grab the appropriate form
        form_name = "Create_%s" % object_class
        form = forms.form_name(request.POST)

        if form.is_valid():
            user = retrieve_object("User", request.session['user_name'])

            try:
                del_object = models.object_class.objects.get(user=user, **form.cleaned_data)
            except:
                print "Error, %s not made" % object_class
                del_object = None

            if del_object is not None:
                project.delete()

    return HttpResponseRedirect('/clouds')
Example #2
0
def Delete_Object(request, object_class):
    """
    Process form to delete an object.
    if the object exists and user is registered,
    deletes object from database.
    """
    if request.method == "POST":
        ## grab the appropriate form
        form_name = "Create_%s" % object_class
        form = forms.form_name(request.POST)

        if form.is_valid():
            user = retrieve_object("User", request.session["user_name"])

            try:
                del_object = models.object_class.objects.get(user=user, **form.cleaned_data)
            except:
                print "Error, %s not made" % object_class
                del_object = None

            if del_object is not None:
                project.delete()

    return HttpResponseRedirect("/clouds")
Example #3
0
def Create_Object(request, object_class):
    """
    Process POST form for generic Object 
    if the object doesn't exist and the user is registered,
    creates the object
    """
    if request.method == "POST":
        ## concatinate object_class with create to get correct form
        form_name = "Create_%s" % object_class
        form = forms.form_name(request.POST)
        
        if form.is_valid():
            user = helpers.Retrieve_Object("User", request.session['user_name'])

            try:
                new_object = models.object_class(user=user, **form.cleaned_data)
            except:
                print "Error, %s not made" % object_class
                new_object = None

            if new_object is not None:
                new_object.save()

    return HttpResponseRedirect('/clouds')
Example #4
0
def Create_Object(request, object_class):
    """
    Process POST form for generic Object 
    if the object doesn't exist and the user is registered,
    creates the object
    """
    if request.method == "POST":
        ## concatinate object_class with create to get correct form
        form_name = "Create_%s" % object_class
        form = forms.form_name(request.POST)

        if form.is_valid():
            user = helpers.Retrieve_Object("User", request.session["user_name"])

            try:
                new_object = models.object_class(user=user, **form.cleaned_data)
            except:
                print "Error, %s not made" % object_class
                new_object = None

            if new_object is not None:
                new_object.save()

    return HttpResponseRedirect("/clouds")