Exemple #1
0
def view_with_employee_list(request,
                            template=None,
                            get_all=False):  # pragma: no cover
    '''Some pages are generic HTML pages with only a select amount of
    differences on them. We use this to generate the employee select
    box and assign the regularly used template variables for these
    templates.
    '''
    user = Tbluser.objects.get(id=request.session.get("user_id", None))

    try:
        ees = user.get_subordinates(get_all=get_all)
        employees_select = generate_employee_box(user, get_all=get_all)
    except tblauth.DoesNotExist:
        ees = []
        employees_select = """<select id=user_select>
                                <option id="null">----------</option>
                              </select>"""

    return render_to_response(
        template, {
            "employees": ees,
            "user_form": UserForm(),
            "employee_option_list": employees_select
        }, RequestContext(request))
Exemple #2
0
def overtime(request, who=None, year=None):
    auth_user = Tbluser.objects.get(id=request.session.get('user_id'))
    if not year:
        year = str(datetime.datetime.now().year)
    if not who:
        try:
            userid = auth_user.get_subordinates()[0].id
            return HttpResponseRedirect("/overtime/%s/%s/" % (userid, year))
        except (tblauth.DoesNotExist, IndexError):
            return HttpResponseRedirect("/user_edit/")

    # stop people from editing the URL to access agents outside their
    # span of control.
    try:
        target_user = auth_user.get_subordinates().get(id=who)
    except Tbluser.DoesNotExist:
        raise Http404

    # generate our year table.
    ot_table = target_user.overtime_view(year)
    # interpolate our values into it.
    ot_table = ot_table.format(
        employees_select=generate_employee_box(auth_user),
        yearbox=generate_year_box(int(year), id="cmb_yearbox"),
        c="EMPTY",
        function="")
    return render_to_response("overtime.html", {
        "ot_table": ot_table,
        "year": year,
        "eeid": who,
    }, RequestContext(request))
def overtime(request, who=None, year=None):
    auth_user = Tbluser.objects.get(
        id=request.session.get('user_id')
        )
    if not year:
        year = str(datetime.datetime.now().year)
    if not who:
        try:
            userid = auth_user.get_subordinates()[0].id
            return HttpResponseRedirect("/overtime/%s/%s/" % (userid, year))
        except (tblauth.DoesNotExist, IndexError):
            return HttpResponseRedirect("/user_edit/")

    # stop people from editing the URL to access agents outside their
    # span of control.
    try:
        target_user = auth_user.get_subordinates().get(id=who)
    except Tbluser.DoesNotExist:
        raise Http404

    # generate our year table.
    ot_table = target_user.overtime_view(year)
    # interpolate our values into it.
    ot_table = ot_table.format(employees_select=generate_employee_box(auth_user),
                               yearbox=generate_year_box(int(year), id="cmb_yearbox"),
                               c="EMPTY",
                               function="")
    return render_to_response("overtime.html",
                              {"ot_table": ot_table,
                               "year": year,
                               "eeid": who,
                               }, RequestContext(request))
def view_with_employee_list(request, template=None, get_all=False): # pragma: no cover
    '''Some pages are generic HTML pages with only a select amount of
    differences on them. We use this to generate the employee select
    box and assign the regularly used template variables for these
    templates.
    '''
    user = Tbluser.objects.get(
        id=request.session.get("user_id", None)
    )

    try:
        ees = user.get_subordinates(get_all=get_all)
        employees_select = generate_employee_box(user, get_all=get_all)
    except tblauth.DoesNotExist:
        ees = []
        employees_select = """<select id=user_select>
                                <option id="null">----------</option>
                              </select>"""

    return render_to_response(
        template,
        {
            "employees": ees,
            "user_form": UserForm(),
            "employee_option_list": employees_select
        },
        RequestContext(request)
    )
Exemple #5
0
def reporting(request):
    '''Base reporting hub
    Generates all the select boxes and pre-filled text fields.
    '''
    user = Tbluser.objects.get(id=request.session.get("user_id"))
    return render_to_response(
        "reporting.html",
        {
            "employee_box": generate_employee_box(user),
            "yearbox_hol": datetime.datetime.now().year,
            "monthbox_hol": generate_month_box("monthbox_hol"),
            "monthbox_ot": generate_month_box("monthbox_ot"),
            "monthbox_hr": generate_month_box("monthbox_hr"),
        },
        RequestContext(request))
Exemple #6
0
def reporting(request): # pragma: no cover
    '''Base reporting hub
    Generates all the select boxes and pre-filled text fields.
    '''
    user = Tbluser.objects.get(id=request.session.get("user_id"))
    return render_to_response(
        "reporting.html",
        {
            "employee_box": generate_employee_box(user),
            "yearbox_hol": datetime.datetime.now().year,
            "monthbox_hol": generate_month_box("monthbox_hol"),
            "monthbox_ot": generate_month_box("monthbox_ot"),
            "monthbox_hr": generate_month_box("monthbox_hr"),
            "monthbox_all": generate_month_box("monthbox_all"),
            "teambox_all": generate_select(MARKET_CHOICES, id="teambox_all"),
        },
        RequestContext(request))
def view_with_holiday_list(request,
                           year=None,
                           month=None,
                           process=None,
                           template=None,
                           admin_required=False):
    """Generates the full holiday table for all employees under a manager
    or a user's teammates if they are a regular user.

    :param request: Automatically passed contains a map of the httprequest
    :return: HttpResponse object back to the browser.
    """


    user = Tbluser.objects.get(id=request.session.get('user_id'))

    if admin_required and not user.sup_tl_or_admin():
        raise Http404

    year = datetime.datetime.today().year if year is None else year
    month = datetime.datetime.today().month if month is None else month

    # django urls parse to unicode objects
    year, month = int(year), int(month)

    holiday_table, comments_list, js_calendar = gen_holiday_list(user,
                                                                 year,
                                                                 month,
                                                                 process)

    # calculate the days in the month, this is inefficient.
    # It creates a list of datetime objects and gets the len
    # of that. Being lazy.
    days_this_month = range(1, len(gen_datetime_cal(year, month))+1)

    return render_to_response(
        template,
        {
            'holiday_table': holiday_table,
            'comments_list': comments_list,
            'days_this_month': days_this_month,
            'employee_select': generate_employee_box(user),
            'js_calendar': js_calendar,
        },
        RequestContext(request))
Exemple #8
0
def view_with_holiday_list(request,
                           year=None,
                           month=None,
                           process=None,
                           template=None,
                           admin_required=False):
    """Generates the full holiday table for all employees under a manager
    or a user's teammates if they are a regular user.

    :param request: Automatically passed contains a map of the httprequest
    :return: HttpResponse object back to the browser.
    """

    user = Tbluser.objects.get(id=request.session.get('user_id'))

    if admin_required and not user.sup_tl_or_admin():
        raise Http404

    year = datetime.datetime.today().year if year is None else year
    month = datetime.datetime.today().month if month is None else month

    # django urls parse to unicode objects
    year, month = int(year), int(month)

    holiday_table, comments_list, js_calendar = gen_holiday_list(
        user, year, month, process)

    # calculate the days in the month, this is inefficient.
    # It creates a list of datetime objects and gets the len
    # of that. Being lazy.
    days_this_month = range(1, len(gen_datetime_cal(year, month)) + 1)

    return render_to_response(
        template, {
            'holiday_table': holiday_table,
            'comments_list': comments_list,
            'days_this_month': days_this_month,
            'employee_select': generate_employee_box(user),
            'js_calendar': js_calendar,
        }, RequestContext(request))
def yearview(request, who=None, year=None): # pragma: no cover
    '''Yearview generates the 'year at a glance' for both Administrators
    and regular users.

    :param who: This will be the ID of an employee which the yearview
    will be generated from if the employee is not within the span
    of control then a 404 will be generated.'''
    auth_user = Tbluser.objects.get(
        id=request.session.get('user_id')
        )

    if not year:
        year = str(datetime.datetime.now().year)
    if not who:
        try:
            userid = auth_user.get_subordinates()[0].id
            return HttpResponseRedirect("/yearview/%s/%s/" % (userid, year))
        except (tblauth.DoesNotExist, IndexError):
            return HttpResponseRedirect("/user_edit/")

    # stop people from editing the URL to access agents outside their
    # span of control.
    try:
        target_user = auth_user.get_subordinates().get(id=who)
    except Tbluser.DoesNotExist:
        raise Http404

    # generate our year table.
    yeartable = target_user.yearview(year)
    # interpolate our values into it.
    yeartable = yeartable.format(employees_select=generate_employee_box(auth_user),
                                 c="EMPTY",
                                 function="")
    return render_to_response("yearview.html",
                              {"yearview_table": yeartable,
                               "year": year,
                               "eeid": who,
                               }, RequestContext(request))
Exemple #10
0
def yearview(request, who=None, year=None):  # pragma: no cover
    '''Yearview generates the 'year at a glance' for both Administrators
    and regular users.

    :param who: This will be the ID of an employee which the yearview
    will be generated from if the employee is not within the span
    of control then a 404 will be generated.'''
    auth_user = Tbluser.objects.get(id=request.session.get('user_id'))

    if not year:
        year = str(datetime.datetime.now().year)
    if not who:
        try:
            userid = auth_user.get_subordinates()[0].id
            return HttpResponseRedirect("/yearview/%s/%s/" % (userid, year))
        except (tblauth.DoesNotExist, IndexError):
            return HttpResponseRedirect("/user_edit/")

    # stop people from editing the URL to access agents outside their
    # span of control.
    try:
        target_user = auth_user.get_subordinates().get(id=who)
    except Tbluser.DoesNotExist:
        raise Http404

    # generate our year table.
    yeartable = target_user.yearview(year)
    # interpolate our values into it.
    yeartable = yeartable.format(
        employees_select=generate_employee_box(auth_user),
        c="EMPTY",
        function="")
    return render_to_response("yearview.html", {
        "yearview_table": yeartable,
        "year": year,
        "eeid": who,
    }, RequestContext(request))