示例#1
0
def deleteGadget(user, short_name, vendor, version):

    result = {'removedIGadgets': []}

    # Remove all igadget that matches this Gadget Resource
    try:

        gadget = Gadget.objects.get(name=short_name, vendor=vendor, version=version)
        igadgets = IGadget.objects.filter(gadget=gadget)
        for igadget in igadgets:
            result['removedIGadgets'].append(igadget.id)
            deleteIGadget(igadget, user)

        gadget.delete()

    except Gadget.DoesNotExist:
        pass

    try:
        uri = "/gadgets/" + vendor + '/' + short_name + '/' + version + '/xhtml'
        xhtml = XHTML.objects.get(uri=uri)
        xhtml.delete()
    except XHTML.DoesNotExist:
        pass

    return result
示例#2
0
def deleteTab (tab, user):
    #Deleting igadgets
    igadgets = IGadget.objects.filter(tab=tab)
    for igadget in igadgets:
        deleteIGadget(igadget, user)
        
    #Deleting OUT connectable (wTab)
    Out.objects.get(abstract_variable = tab.abstract_variable).delete();
    
    #Deleting workspace variable
    WorkSpaceVariable.objects.get(abstract_variable=tab.abstract_variable).delete();
    
    #Deleting abstract variable
    VariableValue.objects.get(abstract_variable=tab.abstract_variable, user=user).delete();
    tab.abstract_variable.delete()
    
    #Deleting tab
    tab.delete()
示例#3
0
class IGadgetEntry(Resource):
    @basicauth_or_logged_in()
    @transaction.commit_on_success
    def delete(self, request, igadget_id, user_name=None):

        # Get the target user, either the user stored in the request or the parameter of the URL
        try:
            user = getTargetUser(request.user, user_name)
        except Exception, e:
            json = json_encode({"message": str(e), "result": "error"})
            return HttpResponseServerError(
                json, mimetype='application/json; charset=UTF-8')

        ig = IGadget.objects.get(id=igadget_id,
                                 tab__workspace__users__id=user.id)
        deleteIGadget(ig, user)
        return HttpResponse(json_encode({"result": "ok"}),
                            mimetype='application/json; charset=UTF-8')
示例#4
0
        except Exception, e:
            json = json_encode({"message": str(e), "result": "error"})
            return HttpResponseServerError(
                json, mimetype='application/json; charset=UTF-8')

        gadget = Gadget.objects.get(id=gadget_id)

        #userWorkspaces =  UserWorkSpace.objects.filter(user=request.user)
        #userTabs = Tab.objects.filter(workspace__in=userWorkspaces)
        #igadgets = IGadget.objects.filter(gadget=gadget, tab__in=userTabs)
        igadgets = IGadget.objects.filter(gadget=gadget,
                                          tab__workspace__users__id=user.id)
        values = []
        for ig in igadgets:
            values.append(ig.id)
            deleteIGadget(ig, user)

        return HttpResponse(json_encode({
            "result": "ok",
            "deleted_igadgets": values
        }),
                            mimetype='application/json; charset=UTF-8')


class IGadgetEntry(Resource):
    @basicauth_or_logged_in()
    @transaction.commit_on_success
    def delete(self, request, igadget_id, user_name=None):

        # Get the target user, either the user stored in the request or the parameter of the URL
        try:
示例#5
0
        try:
            user = getTargetUser(request.user, user_name)
        except Exception, e:
            json = json_encode({"message": str(e), "result": "error"})
            return HttpResponseServerError(json, mimetype='application/json; charset=UTF-8')

        gadget = Gadget.objects.get(id=gadget_id)

        #userWorkspaces =  UserWorkSpace.objects.filter(user=request.user)
        #userTabs = Tab.objects.filter(workspace__in=userWorkspaces)
        #igadgets = IGadget.objects.filter(gadget=gadget, tab__in=userTabs)
        igadgets = IGadget.objects.filter(gadget=gadget, tab__workspace__users__id=user.id)
        values = []
        for ig in igadgets:
            values.append(ig.id)
            deleteIGadget(ig, user)

        return HttpResponse(json_encode({"result": "ok", "deleted_igadgets": values}),
                            mimetype='application/json; charset=UTF-8')


class IGadgetEntry(Resource):

    @basicauth_or_logged_in()
    @transaction.commit_on_success
    def delete(self, request, igadget_id, user_name=None):

        # Get the target user, either the user stored in the request or the parameter of the URL
        try:
            user = getTargetUser(request.user, user_name)
        except Exception, e: