Exemplo n.º 1
0
def rfc_reject(request, id):
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    rfc = ChangeRequest.objects.get(id=id)
    rfc.cur_state = 5
    rfc.save()
    logger.log_action(request.user, rfc, logger.ACTION_REJECT)
    return redirect('/detail/' + id + '/')
Exemplo n.º 2
0
def rfc_confirm(request, id):
    if not tools.has_access(request, ["managers", "tech team"]):
        return permission_denied(request)
    _rfc = ChangeRequest.objects.get(id=id)
    _rfc.cur_state = 2
    logger.log_action(user=request.user, action=logger.ACTION_CONFIRM_TRAFFIC, rfc=_rfc)
    _rfc.save()
    return redirect('/detail/' + id + '/')
Exemplo n.º 3
0
def rfc_reject(request, id):
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    rfc = ChangeRequest.objects.get(id=id)
    rfc.cur_state = 5
    rfc.save()
    logger.log_action(request.user, rfc, logger.ACTION_REJECT)
    return redirect('/detail/' + id + '/')
Exemplo n.º 4
0
def add_rfc(request, rfc_to_edit=None):
    c = tools.default_context(request)
    if not tools.has_access(request, "managers"):
        return permission_denied(request)
    new_rfc = None
    c['title'] = "Add RFC"
    c['new_added'] = True
    c['oper_our'] = Operator.objects.filter(isDirect=True).order_by('fineName')
    c['oper_foreign'] = Operator.objects.all().order_by('fineName')
    # c['priorities'] = dict(ChangeRequest.PRIO_CHOICE)
    if request.method == "POST":
        _author = request.user
        _dt = tools.date_parse_input(request.POST['rfc_date']).date()
        if _dt < date.today():
            return permission_denied(request)
        _comments = request.POST['comments']
        _prio = request.POST['prio']
        _peer_hub = request.POST['peer_hub']
        _oper_our = request.POST['oper_our']
        _oper_foreign = request.POST['oper_foreign']
        _towards = request.POST['towards']
        _backwards = request.POST['backwards']
        new_rfc = ChangeRequest(
            author=_author,
            dt=_dt,
            comments=_comments,
            prio=_prio,
            peer_hub=_peer_hub,
            oper_our=Operator.objects.get(_id=int(_oper_our)),
            oper_foreign=Operator.objects.get(_id=int(_oper_foreign)),
            direction=1 * int(_towards) + 2 * int(_backwards),
        )
        new_rfc.save()
        logger.log_action(user=_author, action=logger.ACTION_ADD_RFC, rfc=new_rfc)
        c['saved'] = "Saved: " + new_rfc.__str__()
        c['link'] = new_rfc.id
        c['new_added'] = False
        c['peer_hub'] = _peer_hub
        c['oper_our_previous'] = Operator.objects.get(_id=int(_oper_our))
        c['oper_foreign_previous'] = Operator.objects.get(_id=int(_oper_foreign))
        c['towards'] = int(_towards)
        c['backwards'] = int(_backwards)
        c['override'] = override.find_overriden(new_rfc)
    if rfc_to_edit is not None:
        # then delete old RFC and create another
        c['title'] = "Edit RFC"
        c['rfc_date'] = rfc_to_edit.dt
        c['oper_our_previous'] = rfc_to_edit.oper_our
        c['oper_foreign_previous'] = rfc_to_edit.oper_foreign
        c['peer_hub'] = rfc_to_edit.peer_hub
        c['comments'] = rfc_to_edit.comments
        c['backwards'] = rfc_to_edit.direction // 2
        c['towards'] = rfc_to_edit.direction % 2
        c['new_added'] = False
        rfc_to_edit.delete()
        if isinstance(new_rfc, ChangeRequest):
            return redirect('/detail/' + str(new_rfc.id))
    return render_to_response('addRFC.html', c)
Exemplo n.º 5
0
def rfc_apply(request, id):
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    _rfc = ChangeRequest.objects.get(id=id)
    if _rfc.cur_state == 0:
        _rfc.cur_state = 1
        logger.log_action(user=request.user, action=logger.ACTION_CONFIRM_ROUTE, rfc=_rfc)
    _rfc.save()
    return redirect('/detail/' + id + '/')
Exemplo n.º 6
0
def oper_sync(request):
    c = tools.default_context(request)
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    c['title'] = "Manage Operators"
    if request.method == "POST":
        c['result'] = sync.sync()[1]
        logger.log_action(request.user, action=logger.ACTION_SYNC_OPERATORS)
    c['opers'] = Operator.objects.all()
    return render_to_response('sync.html', c)
Exemplo n.º 7
0
def oper_sync(request):
    c = tools.default_context(request)
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    c['title'] = "Manage Operators"
    if request.method == "POST":
        c['result'] = sync.sync()[1]
        logger.log_action(request.user, action=logger.ACTION_SYNC_OPERATORS)
    c['opers'] = Operator.objects.all()
    return render_to_response('sync.html', c)
Exemplo n.º 8
0
def rfc_delete(request, id):
    try:
        _rfc = ChangeRequest.objects.get(id=id)
    except ChangeRequest.DoesNotExist:
        return page_not_found(request)
    if not (tools.has_access(request, ["managers"]) and _rfc.cur_state == 0):
        return permission_denied(request)
    logger.log_action(user=request.user, action=logger.ACTION_REMOVE_RFC, rfc=_rfc)
    _rfc.delete()
    return redirect('/list/')
Exemplo n.º 9
0
def rfc_confirm(request, id):
    if not tools.has_access(request, ["managers", "tech team"]):
        return permission_denied(request)
    _rfc = ChangeRequest.objects.get(id=id)
    _rfc.cur_state = 2
    logger.log_action(user=request.user,
                      action=logger.ACTION_CONFIRM_TRAFFIC,
                      rfc=_rfc)
    _rfc.save()
    return redirect('/detail/' + id + '/')
Exemplo n.º 10
0
def untrack_rfc(request, id):
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    rfc = ChangeRequest.objects.get(id=id)
    trackers = Tracker.objects.filter(rfc=rfc)
    rfc.cur_state = 3
    rfc.save(force_update=True)
    for tracker in trackers:
        tracker.delete()
    logger.log_action(request.user, rfc, logger.ACTION_MARK_UNTRACKABLE)
    return redirect('/detail/' + id + '/')
Exemplo n.º 11
0
def rfc_apply(request, id):
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    _rfc = ChangeRequest.objects.get(id=id)
    if _rfc.cur_state == 0:
        _rfc.cur_state = 1
        logger.log_action(user=request.user,
                          action=logger.ACTION_CONFIRM_ROUTE,
                          rfc=_rfc)
    _rfc.save()
    return redirect('/detail/' + id + '/')
Exemplo n.º 12
0
def untrack_rfc(request, id):
    if not tools.has_access(request, "tech team"):
        return permission_denied(request)
    rfc = ChangeRequest.objects.get(id=id)
    trackers = Tracker.objects.filter(rfc=rfc)
    rfc.cur_state = 3
    rfc.save(force_update=True)
    for tracker in trackers:
        tracker.delete()
    logger.log_action(request.user, rfc, logger.ACTION_MARK_UNTRACKABLE)
    return redirect('/detail/' + id + '/')
Exemplo n.º 13
0
def rfc_edit(request, id):
    c = tools.default_context(request)
    c['title'] = "Edit RFC"
    try:
        _rfc = ChangeRequest.objects.get(id=id)
        _rfc_cur_state = _rfc.cur_state
    except ChangeRequest.DoesNotExist:
        _rfc = None
        _rfc_cur_state = 0
    if not (tools.has_access(request, ["managers"]) and _rfc_cur_state == 0):
        return permission_denied(request)
    return add_rfc(request, _rfc)
Exemplo n.º 14
0
def rfc_edit(request, id):
    c = tools.default_context(request)
    c['title'] = "Edit RFC"
    try:
        _rfc = ChangeRequest.objects.get(id=id)
        _rfc_cur_state = _rfc.cur_state
    except ChangeRequest.DoesNotExist:
        _rfc = None
        _rfc_cur_state = 0
    if not (tools.has_access(request, ["managers"]) and _rfc_cur_state == 0):
        return permission_denied(request)
    return add_rfc(request, _rfc)
Exemplo n.º 15
0
def rfc_delete(request, id):
    try:
        _rfc = ChangeRequest.objects.get(id=id)
    except ChangeRequest.DoesNotExist:
        return page_not_found(request)
    if not (tools.has_access(request, ["managers"]) and _rfc.cur_state == 0):
        return permission_denied(request)
    logger.log_action(user=request.user,
                      action=logger.ACTION_REMOVE_RFC,
                      rfc=_rfc)
    _rfc.delete()
    return redirect('/list/')
Exemplo n.º 16
0
def combined_rfc(request, id):
    if request.method == "POST":
        if not tools.has_access(request, "managers"):
            return permission_denied(request)
        chosen_rfcs = [int(k[1:]) for k in request.POST.keys() if k[0] == "c" and request.POST[k]]
        return _docx.inflate_docx(int(id), chosen_rfcs=chosen_rfcs)
    else:
        c = tools.default_context(request)
        c['title'] = "Include to combined RFC"
        rfc_base = ChangeRequest.objects.get(id=id)
        rfcs = ChangeRequest.objects.filter(dt__gte=rfc_base.dt).filter(oper_our=rfc_base.oper_our)
        c['rfcs'] = rfcs
        return render_to_response("combinedRFC.html", c)
Exemplo n.º 17
0
def combined_rfc(request, id):
    if request.method == "POST":
        if not tools.has_access(request, "managers"):
            return permission_denied(request)
        chosen_rfcs = [
            int(k[1:]) for k in request.POST.keys()
            if k[0] == "c" and request.POST[k]
        ]
        return _docx.inflate_docx(int(id), chosen_rfcs=chosen_rfcs)
    else:
        c = tools.default_context(request)
        c['title'] = "Include to combined RFC"
        rfc_base = ChangeRequest.objects.get(id=id)
        rfcs = ChangeRequest.objects.filter(dt__gte=rfc_base.dt).filter(
            oper_our=rfc_base.oper_our)
        c['rfcs'] = rfcs
        return render_to_response("combinedRFC.html", c)
Exemplo n.º 18
0
def add_rfc(request, rfc_to_edit=None):
    c = tools.default_context(request)
    if not tools.has_access(request, "managers"):
        return permission_denied(request)
    new_rfc = None
    c['title'] = "Add RFC"
    c['new_added'] = True
    c['oper_our'] = Operator.objects.filter(isDirect=True).order_by('fineName')
    c['oper_foreign'] = Operator.objects.all().order_by('fineName')
    # c['priorities'] = dict(ChangeRequest.PRIO_CHOICE)
    if request.method == "POST":
        _author = request.user
        _dt = tools.date_parse_input(request.POST['rfc_date']).date()
        if _dt < date.today():
            return permission_denied(request)
        _comments = request.POST['comments']
        _prio = request.POST['prio']
        _peer_hub = request.POST['peer_hub']
        _oper_our = request.POST['oper_our']
        _oper_foreign = request.POST['oper_foreign']
        _towards = request.POST['towards']
        _backwards = request.POST['backwards']
        new_rfc = ChangeRequest(
            author=_author,
            dt=_dt,
            comments=_comments,
            prio=_prio,
            peer_hub=_peer_hub,
            oper_our=Operator.objects.get(_id=int(_oper_our)),
            oper_foreign=Operator.objects.get(_id=int(_oper_foreign)),
            direction=1 * int(_towards) + 2 * int(_backwards),
        )
        new_rfc.save()
        logger.log_action(user=_author,
                          action=logger.ACTION_ADD_RFC,
                          rfc=new_rfc)
        c['saved'] = "Saved: " + new_rfc.__str__()
        c['link'] = new_rfc.id
        c['new_added'] = False
        c['peer_hub'] = _peer_hub
        c['oper_our_previous'] = Operator.objects.get(_id=int(_oper_our))
        c['oper_foreign_previous'] = Operator.objects.get(
            _id=int(_oper_foreign))
        c['towards'] = int(_towards)
        c['backwards'] = int(_backwards)
        c['override'] = override.find_overriden(new_rfc)
    if rfc_to_edit is not None:
        # then delete old RFC and create another
        c['title'] = "Edit RFC"
        c['rfc_date'] = rfc_to_edit.dt
        c['oper_our_previous'] = rfc_to_edit.oper_our
        c['oper_foreign_previous'] = rfc_to_edit.oper_foreign
        c['peer_hub'] = rfc_to_edit.peer_hub
        c['comments'] = rfc_to_edit.comments
        c['backwards'] = rfc_to_edit.direction // 2
        c['towards'] = rfc_to_edit.direction % 2
        c['new_added'] = False
        rfc_to_edit.delete()
        if isinstance(new_rfc, ChangeRequest):
            return redirect('/detail/' + str(new_rfc.id))
    return render_to_response('addRFC.html', c)
Exemplo n.º 19
0
def paper_rfc(request, id):
    if not tools.has_access(request, "managers"):
        return permission_denied(request)
    return _docx.inflate_docx(int(id))
Exemplo n.º 20
0
def paper_rfc(request, id):
    if not tools.has_access(request, "managers"):
        return permission_denied(request)
    return _docx.inflate_docx(int(id))