Beispiel #1
0
def view(request):
    project = get_selected_project(request)

    error_id = request.matchdict["id"]
    try:
        error = Error.objects(project=project.token, id=error_id).get()
    except:
        return HTTPNotFound()

    error.mark_seen(request.user)
    error.save()

    instances = ErrorInstance.objects(hash=error.hash)[:10]

    params = {
        "error": error,
        "selected_project": project,
        "available_projects": Project.objects(),
        "instances": instances,
        "github": GithubLinker(project.github),
    }

    try:
        template = "error-view/" + str(error["language"]).lower() + ".html"
        return render_to_response(template, params)
    except:
        template = "error-view/generic.html"
        return render_to_response(template, params)
Beispiel #2
0
def mass(request):
    error_ids = request.matchdict["ids"].split(",")
    action = request.matchdict["action"]
    project = get_selected_project(request)

    try:
        for error_id in error_ids:
            error = Error.objects(project=project.token, id=error_id).get()

            if action == "claim":
                error.claim(request.user)
            elif action == "unclaim":
                error.remove_claim()
            elif action == "resolve":
                error.resolve(request.user)
            elif action == "unresolve":
                error.unresolve()
            elif action == "markseen":
                error.mark_seen(request.user)
            elif action == "markunseen":
                error.mark_unseen(request.user)
            else:
                raise Exception("Unknown action: " + action)

            error.save()

        return {"type": "success"}
    except Exception, e:
        return {"type": "failure", "reason": e}
Beispiel #3
0
def comment_add(request):
    error_id = request.matchdict["id"]
    project = get_selected_project(request)

    try:
        error = Error.objects(project=project.token, id=error_id).get()

        error.comments.append(
            Comment(author=request.user, content=request.POST.get("comment").strip(), created=int(time()))
        )
        error.save()
        return {"type": "success"}
    except:
        return {"type": "failure"}
Beispiel #4
0
def toggle_resolve(request):
    error_id = request.matchdict["id"]
    project = get_selected_project(request)

    try:
        error = Error.objects(project=project.token, id=error_id).get()

        if error.is_resolved():
            error.unresolve()
        else:
            error.resolve(request.user)
        error.save()

        return {"type": "success"}
    except:
        return {"type": "failure"}
Beispiel #5
0
def tag_remove(request):
    tag = request.matchdict["tag"]
    error_id = request.matchdict["id"]
    project = get_selected_project(request)

    try:
        error = Error.objects(project=project.token, id=error_id).get()

        if tag not in error.tags:
            return {"type": "failure"}

        error.tags.remove(tag)
        error.save()
        Tag.removeOne(tag)
        return {"type": "success"}
    except:
        return {"type": "failure"}
Beispiel #6
0
def tag_add(request):
    tag = request.matchdict["tag"]
    error_id = request.matchdict["id"]
    project = get_selected_project(request)

    try:
        error = Error.objects(project=project.token, id=error_id).get()

        if tag in error.tags:
            return {"type": "failure"}

        error.tags.append(tag)
        error.save()
        Tag.create(tag).save()
        return {"type": "success"}
    except:
        return {"type": "failure"}
Beispiel #7
0
 def errors(self):
     return Error.objects(project=self.token)