예제 #1
0
    def save(self):
        ak = get_client()
        resp = ak.Template.save({
            'id': self.template_id,
            'code': self.new_code
        })

        return resp

        # @@TODO: currently ak template edit history is poorly preserved --
        # edit_type=None and no user name for the author.
        # Should file a feature request with WAWD to make this settable directly on the
        # initial save (I can't figure out how to do this w/the rest api either)
        # because doing it w/additional requests is really inefficient.
        # And also doesn't actually work as written here, because the templatehistory object
        # doesn't seem to make it to the replica db in time for it to be found here...
        hist_obj = None
        try:
            hist_obj = TemplateHistory.objects.using("ak").get(
                templateset__id=id,
                filename=filename,
                code_hash=resp['code_hash'])
        except TemplateHistory.DoesNotExist:
            pass
        if hist_obj is None:
            return redirect("..")

        api = rest_client(safety_net=False)
        data = api.templatehistory.get(hist_obj.id)
        data.pop('id')
        data['user_name'] = request.user.username
        data['edit_type'] = "api_edit"
        api.templatehistory.put(hist_obj.id, data)
예제 #2
0
    def save(self):
        ak = get_client()
        resp = ak.Template.save({"id": self.template_id, "code": self.new_code})

        return resp

        # @@TODO: currently ak template edit history is poorly preserved --
        # edit_type=None and no user name for the author.
        # Should file a feature request with WAWD to make this settable directly on the
        # initial save (I can't figure out how to do this w/the rest api either)
        # because doing it w/additional requests is really inefficient.
        # And also doesn't actually work as written here, because the templatehistory object
        # doesn't seem to make it to the replica db in time for it to be found here...
        hist_obj = None
        try:
            hist_obj = TemplateHistory.objects.using("ak").get(
                templateset__id=id, filename=filename, code_hash=resp["code_hash"]
            )
        except TemplateHistory.DoesNotExist:
            pass
        if hist_obj is None:
            return redirect("..")

        api = rest_client(safety_net=False)
        data = api.templatehistory.get(hist_obj.id)
        data.pop("id")
        data["user_name"] = request.user.username
        data["edit_type"] = "api_edit"
        api.templatehistory.put(hist_obj.id, data)
예제 #3
0
파일: views.py 프로젝트: 350dotorg/akcrm
def edit_skills(request, user_id):
    try:
        agent = CoreUser.objects.using("ak").get(id=user_id)
    except CoreUser.DoesNotExist:
        return HttpResponseNotFound("No such record exists")

    skills = request.POST.getlist("skills")

    actionkit = get_client()
    user = actionkit.User.save({'id': user_id, 'user_skills': skills})
    return HttpResponse(json.dumps(user['custom_fields'].get("skills", [])),
                        content_type="text/plain")
예제 #4
0
파일: rest.py 프로젝트: 350dotorg/akcrm
def create_action(page_id, user_id):
    page_name = CorePage.objects.using("ak").get(id=page_id).name

    actionkit = get_client()
    return actionkit.act({'page': page_name, 'id': user_id})