示例#1
0
def enlist_new_user(request):
    sModuleInfo = getfileInfo(file_path) + inspect.stack()[0][3]
    if request.method == 'POST':
        PassMessasge(
            sModuleInfo, "Registration for user %s:%s is submitted" %
            (request.POST['InputFullName'], request.POST['InputUserName']),
            info_flag)
        current_date_time = datetime.datetime.now()
        temp_user = User()
        temp_user.username = request.POST['InputUserName']
        temp_user.first_name = request.POST['InputFullName']
        temp_user.email = request.POST['InputEmail']
        temp_user.set_password(request.POST['InputPassword'])
        temp_user.date_joined = current_date_time
        if request.POST['InputSection'] == 'A' and request.POST[
                'InputRole'] == 'M':
            temp_user.is_staff = True
        temp_user.save()
        PassMessasge(
            sModuleInfo, "Info for user %s:%s is enlisted in auth_user" %
            (request.POST['InputFullName'], request.POST['InputUserName']),
            info_flag)
        #get the current user password
        current_user_id = User.objects.get(
            first_name__exact=request.POST['InputFullName'],
            username__exact=request.POST['InputUserName'])
        PassMessasge(
            sModuleInfo, "Assigning the busniess setting for user %s:%s" %
            (request.POST['InputFullName'], request.POST['InputUserName']),
            info_flag)
        business_map = user_business_map()
        business_map.user = current_user_id
        business_map.category = request.POST['InputSection']
        business_map.password = request.POST['InputPassword']
        if request.POST['InputRole'] == 'M':
            business_map.is_staff = True
        if request.POST['InputRole'] == 'E':
            business_map.is_staff = False
        business_map.save()
        if request.user.is_authenticated():
            execlog = exec_log()
            execlog.user = request.user
            execlog.section = request.POST['InputSection']
            execlog.action = "Registered"
            execlog.detail = "User %s: Full Name:%s" % (
                request.POST['InputUserName'], request.POST['InputFullName'])
            execlog.save()
        PassMessasge(
            sModuleInfo, "Assiging the business setting for user %s:%s" %
            (request.POST['InputFullName'], request.POST['InputUserName']),
            info_flag)
        return HttpResponseRedirect(reverse('admin.views.ListUser'))
    else:
        PassMessasge(
            sModuleInfo,
            "Registration for user %s:%s is to be a POST request" %
            (request.POST['InputFullName'], request.POST['InputUserName']),
            error_flag)
        return HttpResponseRedirect(reverse('admin.views.AddUser'))
示例#2
0
def home(request):
    sModuleInfo = getfileInfo(file_path) + inspect.stack()[0][3]
    PassMessasge(sModuleInfo, "Redirecting Page", info_flag)
    current_user = user_business_map.objects.filter(category='D').get(
        user_id=request.user.id)
    if current_user.is_staff:
        return HttpResponseRedirect(reverse('drinks.views.manager_home'))
    else:
        return HttpResponseRedirect(reverse('drinks.views.employee_home'))
示例#3
0
def LoginApprove(request):
    sModuleInfo=getfileInfo(file_path)+ inspect.stack()[0][3]
    try:
        if request.method=="POST":
            user_name=request.POST['username']
            password=request.POST['password']
            user=authenticate(username=user_name,password=password)
            if user is not None:
                login(request,user)
                print user
                #user category sending
                current_user=user_business_map.objects.get(user_id=user.id)
                category=current_user.category
                role=current_user.is_staff
                if category=='C':
                    if role:
                        return HttpResponseRedirect(reverse('garments.views.manager_home'))
                    else:
                        return HttpResponseRedirect(reverse('garments.views.employee_home'))
                if category=='D':
                    if role:
                        return HttpResponseRedirect(reverse('drinks.views.manager_home'))
                    else:
                        return HttpResponseRedirect(reverse('drinks.views.employee_home'))
                if category=='G':
                    if role:
                        return HttpResponseRedirect(reverse('groceries.views.manager_home'))
                    else:
                        return HttpResponseRedirect(reverse('groceries.views.employee_home'))
                if category=='L':
                    if role:
                        return HttpResponseRedirect(reverse('lighting.views.manager_home'))
                    else:
                        return HttpResponseRedirect(reverse('lighting.views.employee_home'))
                if category=='A':
                    return HttpResponseRedirect(reverse('admin.views.home'))
            else:
                PassMessasge(sModuleInfo, "(%s,%s)No Such User exists"%(user_name,password),error_flag)
                return HttpResponseRedirect(reverse('InventoryManagement.views.home'))
    except Exception,e:
        PassMessasge(sModuleInfo, str(e),error_flag)
        return HttpResponseRedirect(reverse('InventoryManagement.views.home'))
示例#4
0
def ListUser(request):
    sModuleInfo = getfileInfo(file_path) + inspect.stack()[0][3]
    PassMessasge(sModuleInfo, "Retrieving all the users", info_flag)
    all_users = user_business_map.objects.select_related('user_id')
    final_list = []
    for x in all_users:
        if x.is_staff:
            final_list.append(
                (x.user.first_name, x.user.email, "Manager",
                 x.get_category_display(), x.user.date_joined.date()))
        else:
            final_list.append(
                (x.user.first_name, x.user.email, "Employee",
                 x.get_category_display(), x.user.date_joined.date()))
    #print final_list
    column = ['Full Name', 'Email', 'Section', 'Date Registerd']
    return render_to_response('admin/ListAllUser.html', {
        'user_list': final_list,
        'column': column
    })
示例#5
0
def AddUser(request):
    sModuleInfo = getfileInfo(file_path) + inspect.stack()[0][3]
    PassMessasge(sModuleInfo, "In Add User Page", info_flag)
    return render_to_response('admin/AddUser.html', {},
                              context_instance=RequestContext(request))
示例#6
0
def home(request):
    sModuleInfo = getfileInfo(file_path) + inspect.stack()[0][3]
    PassMessasge(sModuleInfo, "In Admin Home Page", info_flag)
    return render_to_response('admin/Home.html', {})
示例#7
0
def employee_home(request):
    sModuleInfo = getfileInfo(file_path) + inspect.stack()[0][3]
    PassMessasge(sModuleInfo, "In Drinks Employee Home Page", info_flag)
    return render_to_response('drinks/employee/Home.html', {})
示例#8
0
def home(request):
    sModuleInfo=getfileInfo(file_path)+inspect.stack()[0][3]
    PassMessasge(sModuleInfo, "In the Login page",info_flag)
    return  render_to_response('base/signin.html',{},context_instance=RequestContext(request))