Ejemplo n.º 1
0
def view_bug_queries(request):
    if not request.user.is_authenticated():
        return go_home(request)
    try:
        first_query = BugQuery.visible_for_user(request.user)[0]
    except IndexError:
        first_query = None
    if first_query is not None:
        return redirect('view_bug_query', first_query.id)
    else:
        # No Group
        messages.info(request, "No query present, redirected to the homepage.")
        return go_home(request)
Ejemplo n.º 2
0
def view_bug_queries(request):
    if not request.user.is_authenticated():
        return go_home(request)
    try:
        first_query = BugQuery.visible_for_user(request.user)[0]
    except IndexError:
        first_query = None
    if first_query is not None:
        return redirect('view_bug_query', first_query.id)
    else:
        # No Group
        messages.info(request, "No query present, redirected to the homepage.")
        return go_home(request)
Ejemplo n.º 3
0
def new_bug_query(request):
    if not request.user.is_authenticated():
        return go_home(request)
    queries = BugQuery.visible_for_user(request.user)
    query = None
    if request.method == 'GET':
        return render(request, 'bugs/new_query.html', locals())
    elif request.method != 'POST':
        messages.error(request, "Invalid request.")
        return go_home(request)
    # Create a new one
    name = request.POST['name']
    url = request.POST['url']
    global_ = request.POST.get('global', 'false') == 'true'
    if not request.user.is_superuser:
        global_ = False
    if global_:
        owner = None
    else:
        owner = request.user
    bug_query = BugQuery(name=name, url=url, owner=owner)
    bug_query.save()
    messages.info(request, "Query with name {} added.".format(name))
    return redirect('view_bug_query', bug_query.id)
Ejemplo n.º 4
0
def new_bug_query(request):
    if not request.user.is_authenticated():
        return go_home(request)
    queries = BugQuery.visible_for_user(request.user)
    query = None
    if request.method == 'GET':
        return render(request, 'bugs/new_query.html', locals())
    elif request.method != 'POST':
        messages.error(request, "Invalid request.")
        return go_home(request)
    # Create a new one
    name = request.POST['name']
    url = request.POST['url']
    global_ = request.POST.get('global', 'false') == 'true'
    if not request.user.is_superuser:
        global_ = False
    if global_:
        owner = None
    else:
        owner = request.user
    bug_query = BugQuery(name=name, url=url, owner=owner)
    bug_query.save()
    messages.info(request, "Query with name {} added.".format(name))
    return redirect('view_bug_query', bug_query.id)
Ejemplo n.º 5
0
def view_bug_query(request, query_id):
    if not request.user.is_authenticated():
        return go_home(request)
    queries = BugQuery.visible_for_user(request.user)
    query = BugQuery.objects.get(id=query_id)
    if query.owner is not None and query.owner != request.user:
        if not request.user.is_superuser:
            messages.info(request, "You cannot view BugQuery {}.".format(query.id))
            return go_home(request)
    try:
        bugs = query.list_bugs(request.user)
    except xmlrpclib.Fault as e:
        messages.error(request, 'Bugzilla query error {}: {}'.format(e.faultCode, e.faultString))
        return go_home(request)
    return render(request, 'bugs/list_query.html', locals())
Ejemplo n.º 6
0
def view_bug_query(request, query_id):
    if not request.user.is_authenticated:
        return go_home(request)
    queries = BugQuery.visible_for_user(request.user)
    query = BugQuery.objects.get(id=query_id)
    if query.owner is not None and query.owner != request.user:
        if not request.user.is_superuser:
            messages.info(request, "You cannot view BugQuery {}.".format(query.id))
            return go_home(request)
    try:
        bugs = query.list_bugs(request.user)
    except RPCFault as e:
        messages.error(request, 'Bugzilla query error {}: {}'.format(e.faultCode, e.faultString))
        return go_home(request)
    return render(request, 'bugs/list_query.html', locals())