Source

ultrasound / django_ultrasound / employees / views.py

from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from employees.models import *
from django.utils.translation import ugettext as _







@login_required
def employee_home(request):

    user = request.user
    
    employee = Employee.objects.get(user=request.user)
    if employee.employee_type.code == CLUB_MANAGER:
        app_list = [
                { "name": _("activities"),
                  "app_url": "",
                  "models": [
                              {"name": _("Events"), "admin_url": "/admin/events/event/", "perms_add": True, "perms_change": True},
                            ]
                },

                { "name": _("reports"),
                  "app_url": "",
                  "models": [
                              {"name": _("Some report"), "admin_url": "/reports/some_report/",},
                            ]
                },

                { "name": _("administration"),
                  "app_url": "",
                  "models": [
                              {"name": _("Products"), "admin_url": "/admin/products/product/", "perms_add": True, "perms_change": True},
                            ]
                },
        ]

    elif employee.employee_type.code == MAN_POWER:
        app_list = [
                { "name": _("activities"),
                  "app_url": "",
                  "models": [
                              {"name": _("Employees"), "admin_url": "/admin/employees/employee/", "perms_add": True, "perms_change": True},
                            ]
                },
                { "name": _("reports"),
                  "app_url": "",
                  "models": [
                              {"name": _("Man power report"), "admin_url": "/reports/list_employees/",},
                            ]
                },
        ]

    else:
        pass

    return render_to_response("employee_home.html", locals())



def setup_first_user(request):
    if User.objects.filter(username="admin").count() == 0:
        user = User()
        user.username = "admin"
        user.set_password("admin")
        user.email = "rami.zelingher@gmail.com"
        user.is_staff = True
        user.is_superuser = True
        user.save()
        return HttpResponse("First user created")
    else:
        return HttpResponse("User already exists")


@login_required
def change_customer_status(request, customer_id):
    pass
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.