コード例 #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)
コード例 #2
0
ファイル: views.py プロジェクト: rananda/cfme_tests
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)
コード例 #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)
コード例 #4
0
ファイル: views.py プロジェクト: rananda/cfme_tests
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)
コード例 #5
0
ファイル: views.py プロジェクト: rananda/cfme_tests
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())
コード例 #6
0
ファイル: views.py プロジェクト: nachandr/cfme_tests
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())