Пример #1
0
def main():
    arguments = docopt(__doc__, version=__VERSION__, help=True)
    # check if has configuration option set
    config_file = arguments.get("--config")
    if config_file:
        ip, user, password = config.get_config_from_file(config_file)
    else:
        ip, user, password = config.get_config_from_args(arguments)

    router = Router(ip=ip, user=user, password=password)
    router.reboot()
Пример #2
0
def test_router___include():
    router = Router("test")
    router.create_route("detail").pk("pk").path("detail")
    assert router._routes["detail"].to_url() == r"(?P<pk>[0-9]+)/detail/$"

    @router.use_route("detail")
    def view():
        pass

    urlpatterns, _, _ = router.include()
    assert urlpatterns[0].pattern._regex == r"^(?P<pk>[0-9]+)/detail/$"
    assert urlpatterns[0].name == r"test-detail"
Пример #3
0
def test_router__add_child():
    router = Router("test")
    child_router = Router("child")
    router.add_child("extra", child_router)
    child_router.create_route("foo").pk("pk").path("detail")

    @child_router.use_route("foo")
    def view():
        pass

    urlpatterns, _, _ = router.include()
    assert urlpatterns[0].pattern._regex == r"extra/(?P<pk>[0-9]+)/detail/$"
    assert urlpatterns[0].name == r"test-child-foo"
Пример #4
0
def test_adds_first_route():
    router = Router()

    @router.route("route")
    def routed_func():
        pass

    assert len(router.routes) == 1
    assert router.routes[0][0] == "route"
    assert router.routes[0][1] == routed_func
Пример #5
0
def test_adds_more_routes():
    router = Router()

    @router.route("route1")
    def func1():
        pass

    @router.route("route2")
    def func2():
        pass

    assert len(router.routes) == 2
    assert router.routes[1][0] == "route2"
    assert router.routes[1][1] == func2
Пример #6
0
from django.http import Http404
from django.contrib.auth.models import Group
from rest_framework.decorators import api_view
from rest_framework.response import Response

from accounts.models import User, CaseGroups
from case.utils.react import render_react_page
from accounts.models import User
from case.views.auth import coordinator_or_better_required, admin_or_better_required
from case.utils.router import Router
from case.serializers import UserDetailSerializer, IssueListSerializer
from microsoft.service import get_user_permissions
from microsoft.tasks import refresh_ms_permissions

router = Router("user")
router.create_route("perms-resync").pk("pk").path("perms").path("resync")
router.create_route("perms-promote").pk("pk").path("perms").path("promote")
router.create_route("perms-demote").pk("pk").path("perms").path("demote")
router.create_route("perms").pk("pk").path("perms")
router.create_route("detail").pk("pk")

logger = logging.getLogger(__name__)


@router.use_route("detail")
@api_view(["GET", "PATCH"])
@coordinator_or_better_required
def account_detail_view(request, pk):
    try:
        user = (User.objects.prefetch_related(
Пример #7
0
import falcon

from utils.router import Router

from utils.cors import middlewares

app = falcon.API(middleware=middlewares)

Router(app)

# def main():

# main()
Пример #8
0
from django.shortcuts import render
from django.views.decorators.http import require_http_methods
from django.http import Http404

from case.forms import DynamicTableForm, TenancyDynamicForm
from core.models import Tenancy, Issue
from .auth import paralegal_or_better_required
from case.utils.router import Router

TENANCY_DETAIL_FORMS = {
    "form": TenancyDynamicForm,
}

router = Router("tenancy")
router.create_route("detail").pk("pk").slug("form_slug", optional=True)


@router.use_route("detail")
@paralegal_or_better_required
@require_http_methods(["GET", "POST"])
def tenancy_detail_view(request, pk, form_slug: str = ""):
    try:
        tenancy = Tenancy.objects.get(pk=pk)
        if request.user.is_paralegal:
            is_assigned = Issue.objects.filter(
                client=tenancy.client, paralegal=request.user).exists()
            if not is_assigned:
                # Not allowed
                raise Http404()

    except Tenancy.DoesNotExist:
Пример #9
0
from case.utils.router import Router
from microsoft.endpoints import MSGraphAPI
from microsoft.service import save_email_attachment
from case.utils.react import render_react_page
from case.serializers import (
    IssueDetailSerializer,
    EmailSerializer,
    EmailAttachmentSerializer,
    EmailThreadSerializer,
)
from case.views.case.detail import get_detail_urls

DISPLAY_EMAIL_STATES = [EmailState.SENT, EmailState.INGESTED]
DRAFT_EMAIL_STATES = [EmailState.READY_TO_SEND, EmailState.DRAFT]

router = Router("email")
router.create_route("list").uuid("pk")
router.create_route("thread").uuid("pk").path("thread").slug("slug")
router.create_route("draft").uuid("pk").path("draft")
router.create_route("edit").uuid("pk").path("draft").pk("email_pk")
router.create_route("send").uuid("pk").path("draft").pk("email_pk").path(
    "send")
router.create_route("preview").uuid("pk").path("draft").pk("email_pk").path(
    "preview")
(router.create_route("attach").uuid("pk").path("draft").pk("email_pk").path(
    "attachment").pk("attach_pk", optional=True))
router.create_route("attach-upload").uuid("pk").pk("email_pk").pk("attach_pk")


@router.use_route("list")
@paralegal_or_better_required
Пример #10
0
from django.urls import reverse
from rest_framework import status
from rest_framework.response import Response
from rest_framework.decorators import api_view

from emails.models import EmailTemplate
from case.utils.router import Router
from core.models.issue import CaseTopic
from case.forms import DocumentTemplateForm
from microsoft.service import list_templates, upload_template, delete_template
from case.utils.react import render_react_page
from case.serializers import EmailTemplateSerializer

from .auth import coordinator_or_better_required, paralegal_or_better_required

router = Router("template")
router.create_route("list")
router.create_route("email-list").path("email")
router.create_route("email-detail").path("email").pk("pk")
router.create_route("email-create").path("email").path("create")
router.create_route("email-search").path("email").path("search")
router.create_route("doc-list").path("doc")
router.create_route("doc-create").path("doc").path("create")
router.create_route("doc-search").path("doc").path("search")
router.create_route("doc-delete").path("doc").slug("file_id").path("delete")


@router.use_route("list")
@coordinator_or_better_required
@require_http_methods(["GET"])
def template_list_view(request):
Пример #11
0
from django.http import Http404
from rest_framework.decorators import api_view
from rest_framework.response import Response

from case.serializers import ClientDetailSerializer
from core.models import Client, Issue
from case.utils.router import Router
from case.utils.react import render_react_page

from .auth import paralegal_or_better_required

router = Router("client")
router.create_route("detail").uuid("pk")


@router.use_route("detail")
@paralegal_or_better_required
@api_view(["GET", "PATCH"])
def client_detail_view(request, pk):
    try:
        client = Client.objects.prefetch_related("issue_set").get(pk=pk)
        if request.user.is_paralegal:
            is_assigned = Issue.objects.filter(
                client=client, paralegal=request.user).exists()
            if not is_assigned:
                # Not allowed
                raise Http404()
    except Client.DoesNotExist:
        raise Http404()

    if request.method == "GET":
Пример #12
0
def test_starts_with_empty_routes():
    router = Router()
    assert len(router.routes) == 0
Пример #13
0
from case.utils.router import Router

from .list import (
    list_route,
    inbox_route,
    review_route,
    checks_route,
    review_search_route,
)
from .detail import router as detail_router
from .email import router as email_router
from .docs import docs_route, docs_sharepoint_route

router = Router("case")
router.add_child("email/", email_router)
router.add_child("detail/", detail_router)
router.add_route(list_route)
router.add_route(inbox_route)
router.add_route(review_search_route)
router.add_route(review_route)
router.add_route(docs_route)
router.add_route(docs_sharepoint_route)
router.add_route(checks_route)
Пример #14
0
from django.db.models import Count, Max, Q, F, Case, When

from accounts.models import User
from .auth import coordinator_or_better_required
from case.utils.router import Router
from case.utils.react import render_react_page
from case.serializers import ParalegalSerializer
from accounts.models import CaseGroups

router = Router("paralegal")
router.create_route("list")


@router.use_route("list")
@coordinator_or_better_required
def paralegal_list_view(request):
    paralegals = User.objects.filter(
        groups__name__in=[CaseGroups.PARALEGAL, CaseGroups.COORDINATOR
                          ]).prefetch_related("issue_set", "groups")
    lawyers = User.objects.filter(
        groups__name=CaseGroups.LAWYER).prefetch_related(
            "issue_set", "groups")
    paralegals = _calculate_user_capacity(paralegals, "issue")
    lawyers = _calculate_user_capacity(lawyers, "lawyer_issue")
    context = {
        "paralegals": ParalegalSerializer(paralegals, many=True).data,
        "lawyers": ParalegalSerializer(lawyers, many=True).data,
    }
    return render_react_page(request, f"Paralegals", "paralegal-list", context)

Пример #15
0
from case.utils.router import Router
from .list import list_route
from .detail import router as detail_router
from .create import create_route

router = Router("account")
router.add_child("user/", detail_router)
router.add_route(list_route)
router.add_route(create_route)
Пример #16
0
from rest_framework.decorators import api_view
from rest_framework.response import Response

from case.utils.router import Router
from case.views.auth import paralegal_or_better_required, coordinator_or_better_required
from core.models import Issue, IssueNote, Person
from case.utils.react import render_react_page
from case.serializers import (
    IssueDetailSerializer,
    TenancySerializer,
    IssueNoteSerializer,
    IssueNoteCreateSerializer,
    IssueAssignmentSerializer,
)

router = Router("detail")
router.create_route("view").uuid("pk")
router.create_route("note").uuid("pk").path("note")
router.create_route("update").uuid("pk").path("update")
router.create_route("assign").uuid("pk").path("assign")
router.create_route("landlord").uuid("pk").path("landlord").pk("person_pk",
                                                               optional=True)
router.create_route("agent").uuid("pk").path("agent").pk("person_pk",
                                                         optional=True)


@router.use_route("view")
@paralegal_or_better_required
@api_view(["GET"])
def case_detail_view(request, pk):
    """
Пример #17
0
from utils.router import Router

routes = Router()


@routes.route('/')
def index():
    return "Welcome Home!"
Пример #18
0
from rest_framework.decorators import api_view
from rest_framework.response import Response

from case.serializers import PersonSerializer
from case.utils.react import is_react_api_call
from case.forms import DynamicTableForm, PersonDynamicForm, PersonForm
from core.models import Person, Issue
from .auth import paralegal_or_better_required
from case.utils.router import Router


PERSON_DETAIL_FORMS = {
    "form": PersonDynamicForm,
}

router = Router("person")
router.create_route("detail").pk("pk").slug("form_slug", optional=True)
router.create_route("create").path("create")
router.create_route("search").path("search")
router.create_route("list")


@router.use_route("create")
@paralegal_or_better_required
@require_http_methods(["GET", "POST"])
def person_create_view(request):
    if request.method == "POST":
        form = PersonForm(request.POST)
        if form.is_valid():
            person = form.save()
            return redirect("person-detail", person.pk)
Пример #19
0
# Third Party Imports
import dash
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash_core_components as dcc
import dash_table
from dash.dependencies import Input, Output

# Local Imports
from gui.app import app
from utils.router import Router

router = Router()

page = html.Div(children=[
    dbc.Row([

        # DASHBOARD
        dbc.Col([

            # GENERAL INFO
            html.Div([
                dbc.Card([
                    dbc.CardHeader(html.P('Account Balance', className='label')),
                    dbc.CardBody([
                        html.P('$3203.71')
                    ])
                ])
            ], className='dashboard-element-div'),

            # POSITIONS