Beispiel #1
0
def noticeitemIndex(HttpRequest,page,item):
    try:
        msglist = AppendMessageList(HttpRequest)
        logindetails = GetLoginDetails(HttpRequest)
        if( logindetails["userid"] == -1):
            msglist.append('Please Login to continue')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            #return render_to_response("TwoColumnMaster.html",{'type':['NOTICE'],'title':"Notices"},context_instance=RequestContext(HttpRequest))
            
            return HttpResponseRedirect('/user/login/')
        else:
            item=int(item)
            res=GetCommunicationFnx().getNCommunicationsbyPageIndex("NOTICES", index=int(page))
            if(res[0]==-1 ):
                return HttpResponse("OOPS PAGE REQUESTED DOESNOT EXIST")
            elif(res[0]==-5):
                return HttpResponse("OOPS!!!! Something went wrong....Please Try sometime later, while we try to fix it")
            else:
                #print res
                for i in res[0]:
                    if(i.id==item):
                        M=i
                ##print loads(M.Title.decode("base64").decode("zip"))
                #print list
                list1=[]
                list1.append(str(loads(M.Title.decode("base64").decode("zip"))))
                list1.append(str(M.Timestamp))
                list1.append(str(loads(M.Content.decode("base64").decode("zip"))))
                list1=zip(list1)
                return render_to_response("Communication/User/ViewNewsitem.html",{'message':list1},context_instance=RequestContext(HttpRequest))
    except:
            return HttpResponse("OOPS PAGE REQUESTED DOESNOT EXIST")
Beispiel #2
0
def GroupSecurity(HttpRequest, ctid):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META["REMOTE_ADDR"]
    logindetails = GetLoginDetails(HttpRequest)
    print ctid
    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    try:
        ContentTypeObj = ContentTypeFnx()
        ContentSecurityList = ContentTypeObj.getGroupSecuritybyContentTypes(ctid)
        if ContentSecurityList[0] == 1:
            ContentSecurityList = ContentSecurityList[1]
            if len(ContentSecurityList) == 0:
                msglist.append("There are no content types in the system yet")
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response(
                "SecuritySystem/GroupContentSecurity.html",
                {"ContentSecurityList": ContentSecurityList, "GroupSecurityList": "true"},
                context_instance=RequestContext(HttpRequest),
            )
        else:
            msglist.append("Error Occured while fetching your request")
            HttpRequest.session[SESSION_MESSAGE] = msglist
            HttpResponseRedirect("/message/")
    except:
        Logger_User.exception("[%s][%s] == EXCEPTION ==" % ("GroupSecurity", ip))
        msglist.append("Error Occured while fetching your request")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect("/message/")
Beispiel #3
0
def ListAllStates(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        StateFnxObj  = StateFnx()
        StateList = StateFnxObj.ListAllStates()
        if(StateList[0] == 1):
            StateList  = StateList[1]
            if( len (StateList) == 0):
                msglist.append('There are no states in the system yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("SecuritySystem/EditStates.html",{'StateList':StateList,'EditStateCreate':'false','EditStateList':'true','init_t':0,},context_instance=RequestContext(HttpRequest))
        else:
            msglist.append('Error Occured while fetching your request')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            HttpResponseRedirect('/message/')
    except:
        Logger_User.exception('[][] == EXCEPTION =='%('ListAllStates',ip))
        msglist.append('Error Occured while fetching your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect('/message/')
Beispiel #4
0
def GroupTypeIndex(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        GroupTypeFnxObj  = GroupTypeFnx()
        GroupTypeList = GroupTypeFnxObj.ListAllGroupTypes()
        if(GroupTypeList[0] == 1):
            GroupTypeList  = GroupTypeList[1]
            if( len (GroupTypeList) == 0):
                msglist.append('There are no group types in the system yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("UserSystem/GroupTypes/EditGroupTypes.html",{'grouptypelist':GroupTypeList,'GroupTypesCreate':'true','GroupTypesList':'true',},context_instance=RequestContext(HttpRequest))
        else:
            msglist.append('Error Occured while fetching your request')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            HttpResponseRedirect('/message/')
    except:
        Logger_User.exception('[][] == EXCEPTION =='%('GroupTypeIndex',ip))
        msglist.append('Error Occured while fetching your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect('/message/')
def SessionTypeUpdate(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    print logindetails
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        MarksObj=Marks()
        flag=1
        if "SessionTypeId" in HttpRequest.POST:
            SessionTypeId=HttpRequest.POST["SessionTypeId"]
        else:
            msglist.append("Error fetching data from form for SessionTypeId");
            flag=-1;
        if "SessionTypeName" in HttpRequest.POST:
            SessionTypeName=HttpRequest.POST["SessionTypeName"]
        else:
            msglist.append("Error fetching data from form for SessionTypeName");
            flag=-1;
        if flag==-1:
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("UserProfile/Message.html",{'mylist':msglist,})
        result=MarksObj.UpdateSessionType(SessionTypeId, SessionTypeName,logindetails["userid"], ip)
        msglist.append("result is %s"%result);
        return render_to_response("UserProfile/Message.html",{'mylist':msglist,})
    except Exception as inst:
        print type(inst)     # the exception instance
        print inst.args      # arguments stored in .args
        print inst           # __str__ allows args to printed directly
        x, y = inst.args
        print 'x =', x
        print 'y =', y
def DegreeUpdate(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META["REMOTE_ADDR"]
    logindetails = GetLoginDetails(HttpRequest)
    print logindetails
    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    try:
        MarksObj = Marks()
        flag = 1
        if "DegreeId" in HttpRequest.POST:
            DegreeId = HttpRequest.POST["DegreeId"]
        else:
            msglist.append("Error fetching data from form for DegreeId")
            flag = -1
        if "DegreeName" in HttpRequest.POST:
            DegreeName = HttpRequest.POST["DegreeName"]
        else:
            msglist.append("Error fetching data from form for DegreeName")
            flag = -1
        if flag == -1:
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("UserProfile/Message.html", {"mylist": msglist})
        result = MarksObj.UpdateDegree(DegreeId, DegreeName, logindetails["userid"], ip)
        msglist.append("result is %s" % result)
        return render_to_response("UserProfile/Message.html", {"mylist": msglist})
    except Exception as inst:
        print type(inst)  # the exception instance
        print inst.args  # arguments stored in .args
        print inst  # __str__ allows args to printed directly
        x, y = inst.args
        print "x =", x
        print "y =", y
Beispiel #7
0
def GroupSecurity(HttpRequest,ctid):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    print ctid
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        ContentTypeObj  = ContentTypeFnx()
        ContentSecurityList = ContentTypeObj.getGroupSecuritybyContentTypes(ctid)
        if(ContentSecurityList[0] == 1):
            ContentSecurityList  = ContentSecurityList[1]
            if( len (ContentSecurityList) == 0):
                msglist.append('There are no content types in the system yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("SecuritySystem/GroupContentSecurity.html",{'ContentSecurityList':ContentSecurityList,'GroupSecurityList':'true'},context_instance=RequestContext(HttpRequest))
        else:
            msglist.append('Error Occured while fetching your request')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            HttpResponseRedirect('/message/')
    except:
        Logger_User.exception('[%s][%s] == EXCEPTION =='%('GroupSecurity',ip))
        msglist.append('Error Occured while fetching your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect('/message/')
Beispiel #8
0
def adminNoticeIndex(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    logindetails = GetLoginDetails(HttpRequest)
    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    else:
        return render_to_response(
            "Communication/Admin/PostNotices.html",
            {"type": ["NOTICE"], "title": "Post Notice"},
            context_instance=RequestContext(HttpRequest),
        )
def MarksIndex(HttpRequest):
  msglist = AppendMessageList(HttpRequest)
  logindetails = GetLoginDetails(HttpRequest)
  if( logindetails["userid"] == -1):
    msglist.append('Please Login to continue')
    HttpRequest.session[SESSION_MESSAGE] = msglist
    return HttpResponseRedirect('/user/login/')
  else:
    if( StudentDetails.objects.filter(User=logindetails["userid"]).exists()):
        StudDetailStatus= True
    else:
        StudDetailStatus= False
    return render_to_response("UserProfile/MarksCategory.html",context_instance=RequestContext(HttpRequest))
Beispiel #10
0
def noticeIndex(HttpRequest, token):
    msglist = AppendMessageList(HttpRequest)
    logindetails = GetLoginDetails(HttpRequest)
    if (logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        #return render_to_response("TwoColumnMaster.html",{'type':['NOTICE'],'title':"Notices"},context_instance=RequestContext(HttpRequest))

        return HttpResponseRedirect('/user/login/')
    else:
        res = GetCommunicationFnx().getNCommunicationsbyPageIndex(
            "NOTICES", index=int(token))
        if (res[0] == -1):
            return HttpResponse("OOPS PAGE REQUESTED DOESNOT EXIST")
        elif (res[0] == -5):
            return HttpResponse(
                "OOPS!!!! Something went wrong....Please Try sometime later, while we try to fix it"
            )
        else:
            list2 = []

            for i in res[0]:
                list1 = []
                list1.append(loads(i.Title.decode("base64").decode("zip")))
                list1.append(i.Timestamp)
                list1.append(i.User)
                content = loads(i.Content.decode("base64").decode("zip"))
                content = replaceContentUrls(content)
                preview = content.split(" ")
                preview = preview[:40]
                preview.append(".....")
                preview = " ".join(preview)
                list1.append(preview)
                list1.append(content)
                list1.append(i.id)
                list2.append(list1)

            list1 = zip(list2)

        return render_to_response("Communication/User/ViewNotices.html", {
            'pagerange': res[3],
            'next': res[1],
            'next_p': int(token) + 1,
            'prev_p': int(token) - 1,
            'prev': res[2],
            'list': list1,
            'title': "Notices"
        },
                                  context_instance=RequestContext(HttpRequest))
def AdminIndex(HttpRequest):
	msglist = AppendMessageList(HttpRequest)
	ip = HttpRequest.META['REMOTE_ADDR']
	try:
		isLoggedIn = 'false'
		#if logged in 
		if SYSTEM_INITIALISE_SESSION_NAME in HttpRequest.session.keys():
			isLoggedIn = 'true'
		HttpRequest.session[SESSION_MESSAGE] = msglist
		return render_to_response("SecuritySystem/Admin/SecurityAdminLogin.html",{'isLoggedIn':isLoggedIn},context_instance=RequestContext(HttpRequest))
	except:
		msg = "== UNKNOWN SYSTEM EXCEPTION GENERATED =="
        	InitAdminLogger.exception('[%s][%s] %s'%('AdminIndex',ip,msg))
        	msglist.append(msg)
        	HttpRequest.session[SESSION_MESSAGE] = msglist
        	return HttpResponseRedirect('/user/login/')
Beispiel #12
0
def CreateNewStateIndex(HttpRequest,init):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    #print logindetails
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return render_to_response("SecuritySystem/EditStates.html",{'StateList':{},'EditStateCreate':'true','EditStateList':'false','init_t':init,},context_instance=RequestContext(HttpRequest))
    except:
        Logger_User.exception('[][] == EXCEPTION =='%('CreateNewStateIndex',ip))
        msglist.append('Error Occured while fetching your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect('/message/')
Beispiel #13
0
def GroupSecurityCreateIndex(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        ContentTypeObj  = ContentTypeFnx()
        StatesObj = StateFnx()
        PermissionObj = PermissionFnx()
        GroupObj = GroupFnx()
        ContentSecurityList = ContentTypeObj.getDjangoContentTypes()
        StatesList = StatesObj.ListAllStates()
        PermissionsList = PermissionObj.ListAllPermissions()
        GroupsList = GroupObj.ListAllGroups()
        if(ContentSecurityList[0] == 1 and StatesList[0] == 1 and PermissionsList[0] == 1 and GroupsList[0] == 1):
            ContentSecurityList  = ContentSecurityList[1]
            StatesList = StatesList[1]
            PermissionsList = PermissionsList[1]
            GroupsList = GroupsList[1]
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("SecuritySystem/GroupContentSecurity.html",{'ContentSecurityList':ContentSecurityList,'StatesList':StatesList,'PermissionsList':PermissionsList,'GroupList':GroupsList,'GroupSecurityInsert':'true','GroupSecurityList':'false'},context_instance=RequestContext(HttpRequest))
        else:
            msglist.append('Error Occured while fetching your request')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            HttpResponseRedirect('/message/')
    except:
        Logger_User.exception('[%s][%s] == EXCEPTION =='%('GroupSecurityCreate',ip))
        msglist.append('Error Occured while fetching your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect('/message/')
def DegreeTypeSelect(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    print logindetails
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        mylist=DegreeType.objects.all()
        
        return render_to_response("UserProfile/ViewData.html",{'mydata':mylist,})
        
    except Exception as inst:
        print type(inst)     # the exception instance
        print inst.args      # arguments stored in .args
        print inst           # __str__ allows args to printed directly
        x, y = inst.args
        print 'x =', x
        print 'y =', y
def BoardSelect(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META["REMOTE_ADDR"]
    logindetails = GetLoginDetails(HttpRequest)
    print logindetails
    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    try:
        mylist = Board.objects.all()

        return render_to_response("UserProfile/ViewData.html", {"mydata": mylist})

    except Exception as inst:
        print type(inst)  # the exception instance
        print inst.args  # arguments stored in .args
        print inst  # __str__ allows args to printed directly
        x, y = inst.args
        print "x =", x
        print "y =", y
Beispiel #16
0
def noticeitemIndex(HttpRequest, page, item):
    try:
        msglist = AppendMessageList(HttpRequest)
        logindetails = GetLoginDetails(HttpRequest)
        if (logindetails["userid"] == -1):
            msglist.append('Please Login to continue')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            #return render_to_response("TwoColumnMaster.html",{'type':['NOTICE'],'title':"Notices"},context_instance=RequestContext(HttpRequest))

            return HttpResponseRedirect('/user/login/')
        else:
            item = int(item)
            res = GetCommunicationFnx().getNCommunicationsbyPageIndex(
                "NOTICES", index=int(page))
            if (res[0] == -1):
                return HttpResponse("OOPS PAGE REQUESTED DOESNOT EXIST")
            elif (res[0] == -5):
                return HttpResponse(
                    "OOPS!!!! Something went wrong....Please Try sometime later, while we try to fix it"
                )
            else:
                #print res
                for i in res[0]:
                    if (i.id == item):
                        M = i
                ##print loads(M.Title.decode("base64").decode("zip"))
                #print list
                list1 = []
                list1.append(str(loads(
                    M.Title.decode("base64").decode("zip"))))
                list1.append(str(M.Timestamp))
                list1.append(
                    str(loads(M.Content.decode("base64").decode("zip"))))
                list1 = zip(list1)
                return render_to_response(
                    "Communication/User/ViewNewsitem.html", {'message': list1},
                    context_instance=RequestContext(HttpRequest))
    except:
        return HttpResponse("OOPS PAGE REQUESTED DOESNOT EXIST")
Beispiel #17
0
def noticeIndex(HttpRequest,token):
    msglist = AppendMessageList(HttpRequest)
    logindetails = GetLoginDetails(HttpRequest)
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        #return render_to_response("TwoColumnMaster.html",{'type':['NOTICE'],'title':"Notices"},context_instance=RequestContext(HttpRequest))
        
        return HttpResponseRedirect('/user/login/')
    else:
            res=GetCommunicationFnx().getNCommunicationsbyPageIndex("NOTICES", index=int(token))
            if(res[0]==-1 ):
                return HttpResponse("OOPS PAGE REQUESTED DOESNOT EXIST")
            elif(res[0]==-5):
                return HttpResponse("OOPS!!!! Something went wrong....Please Try sometime later, while we try to fix it")
            else:
                list2=[]
                
                for i in res[0]:
                    list1=[]
                    list1.append(loads(i.Title.decode("base64").decode("zip")))
                    list1.append(i.Timestamp)
                    list1.append(i.User)
                    content=loads(i.Content.decode("base64").decode("zip"))
                    content=replaceContentUrls(content)
                    preview=content.split(" ")
                    preview=preview[:40]
                    preview.append(".....")
                    preview= " ".join(preview)
                    list1.append(preview)
                    list1.append(content)
                    list1.append(i.id)
                    list2.append(list1)
                  
                list1=zip(list2)
                
                
                
            return render_to_response("Communication/User/ViewNotices.html",{'pagerange':res[3],'next':res[1],'next_p':int(token)+1,'prev_p':int(token)-1,'prev':res[2],'list':list1,'title':"Notices"},context_instance=RequestContext(HttpRequest))
Beispiel #18
0
def adminNewsPost(HttpRequest):

    msglist = AppendMessageList(HttpRequest)
    logindetails = GetLoginDetails(HttpRequest)
    ip = HttpRequest.META["REMOTE_ADDR"]

    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    else:
        try:
            print "1"
            comm_call = CommunicationFunctions.PostCommunicationFnx()
            print "2"
            title = HttpRequest.POST["Title"]
            _content = HttpRequest.POST["Content"]
            print "fine"
            tstamp = datetime.datetime.strptime(HttpRequest.POST["date_"], "%m/%d/%Y")
            # print "fine2"
            # print str(tstamp)

            print "here"
            result = comm_call.PostNews(title, _content, tstamp, logindetails["userid"], ip)
            print result
            if result["result"] == -2:
                return HttpResponseRedirect("/user/login")
            elif result["result"] == 1:
                msglist.append("Notice Posted Successfully")
            else:
                msglist.append(result[1])
            HttpRequest.session[SESSION_MESSAGE] = msglist
            print msglist
            return HttpResponseRedirect("/message/")

        except Exception as inst:
            LogUser.exception("[%s][%s] == EXCEPTION ==" % (ip, "NoticePost"))
            msglist.append("Some Error has occoured")
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect("/message/")
Beispiel #19
0
def adminNoticePost(HttpRequest):

    msglist = AppendMessageList(HttpRequest)
    logindetails = GetLoginDetails(HttpRequest)
    ip = HttpRequest.META["REMOTE_ADDR"]

    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    else:
        try:
            comm_call = CommunicationFunctions.PostCommunicationFnx()
            title = HttpRequest.POST["Title"]
            _content = HttpRequest.POST["Content"]
            Users = "0"

            result = comm_call.PostNotice(
                title, _content, datetime.datetime.now(), Users, "Notice Post by Admin", logindetails["userid"], ip
            )
            # msglist.append(result[1])
            if result[1]["result"] == -2:
                return HttpResponseRedirect("/user/login")
            elif result[1]["result"] == 1:
                msglist.append("Notice Posted Successfully")
            else:
                msglist.append(result[1])
            print msglist
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect("/message/")

        except Exception as inst:
            LogUser.exception("[%s][%s] == EXCEPTION ==" % (ip, "NoticePost"))
            msglist.append("Some Error has occoured")
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect("/message/")
Beispiel #20
0
def GroupSecurityCreateIndex(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META["REMOTE_ADDR"]
    logindetails = GetLoginDetails(HttpRequest)
    if logindetails["userid"] == -1:
        msglist.append("Please Login to continue")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect("/user/login/")
    try:
        ContentTypeObj = ContentTypeFnx()
        StatesObj = StateFnx()
        PermissionObj = PermissionFnx()
        GroupObj = GroupFnx()
        ContentSecurityList = ContentTypeObj.getDjangoContentTypes()
        StatesList = StatesObj.ListAllStates()
        PermissionsList = PermissionObj.ListAllPermissions()
        GroupsList = GroupObj.ListAllGroups()
        if ContentSecurityList[0] == 1 and StatesList[0] == 1 and PermissionsList[0] == 1 and GroupsList[0] == 1:
            ContentSecurityList = ContentSecurityList[1]
            StatesList = StatesList[1]
            PermissionsList = PermissionsList[1]
            GroupsList = GroupsList[1]
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response(
                "SecuritySystem/GroupContentSecurity.html",
                {
                    "ContentSecurityList": ContentSecurityList,
                    "StatesList": StatesList,
                    "PermissionsList": PermissionsList,
                    "GroupList": GroupsList,
                    "GroupSecurityInsert": "true",
                    "GroupSecurityList": "false",
                },
                context_instance=RequestContext(HttpRequest),
            )
        else:
            msglist.append("Error Occured while fetching your request")
            HttpRequest.session[SESSION_MESSAGE] = msglist
            HttpResponseRedirect("/message/")
    except:
        Logger_User.exception("[%s][%s] == EXCEPTION ==" % ("GroupSecurityCreate", ip))
        msglist.append("Error Occured while fetching your request")
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect("/message/")
Beispiel #21
0
def AddUserForReg(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    details = GetLoginDetails(HttpRequest)
    if( details['userid'] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
    	UserRegFnxObj = UserRegFnx()
    	_SelectedUsers = HttpRequest.POST.getlist('SelectedUsers')
    	_App_label,_Model = str(HttpRequest.POST['ContentType']).split('-')
    	_Record = int(HttpRequest.POST['RecordID'])
    	print _SelectedUsers,_App_label,_Model,_Record
    	result =  UserRegFnxObj.AdduserData(_App_label,_Model,_Record,'test',_SelectedUsers,int(details['userid']),ip)
    	msglist.append(result)
    	HttpRequest.session[SESSION_MESSAGE] = msglist
    	HttpResponseRedirect('/userreg/users/')
    except:
    	Logger.exception('[%s][%s] == EXCEPTION ==' % (ip, 'AddUserForReg'))
        msglist.append('Some Error has occoured')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
def MarksUpdate(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    print logindetails
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        MarksObj=Marks()
        
        flag=1
        if "Id" in HttpRequest.POST:
            Id=HttpRequest.POST["Id"]
        else:
            msglist.append("Error fetching data from form for SessionStart");
            flag=-1;
        
        if "SessionStart" in HttpRequest.POST:
            SessionStart=HttpRequest.POST["SessionStart"]
        else:
            msglist.append("Error fetching data from form for SessionStart");
            flag=-1;
        if "SessionEnd" in HttpRequest.POST:
            SessionEnd=HttpRequest.POST["SessionEnd"]
        else:
            msglist.append("Error fetching data from form for SessionEnd");
            flag=-1;
        if "SessionNumber" in HttpRequest.POST:
            SessionNumber=HttpRequest.POST["SessionNumber"]
        else:
            msglist.append("Error fetching data from form for SessionNumber");
            flag=-1;
        if "SessionType" in HttpRequest.POST:
            SessionType=HttpRequest.POST["SessionType"]
        else:
            msglist.append("Error fetching data from form for SessionType");
            flag=-1;
        if "TotaMarks" in HttpRequest.POST:
            TotaMarks=HttpRequest.POST["TotaMarks"]
        else:
            msglist.append("Error fetching data from form for TotaMarks");
            flag=-1;
        if "SecuredMarks" in HttpRequest.POST:
            SecuredMarks=HttpRequest.POST["SecuredMarks"]
        else:
            msglist.append("Error fetching data from form for SecuredMarks");
            flag=-1;
        if "TotalReappears" in HttpRequest.POST:
            TotalReappears=HttpRequest.POST["TotalReappears"]
        else:
            msglist.append("Error fetching data from form for TotalReappears");
            flag=-1;
        if "ReappearsRemaining" in HttpRequest.POST:
            ReappearsRemaining=HttpRequest.POST["ReappearsRemaining"]
        else:
            msglist.append("Error fetching data from form for ReappearsRemaining");
            flag=-1;
        if "DegreeType" in HttpRequest.POST:
            DegreeType=HttpRequest.POST["DegreeType"]
        else:
            msglist.append("Error fetching data from form for DegreeType");
            flag=-1;
        if "Board" in HttpRequest.POST:
            Board=HttpRequest.POST["Board"]
        else:
            msglist.append("Error fetching data from form for Board");
            flag=-1;
        if "Degree" in HttpRequest.POST:
            Degree=HttpRequest.POST["Degree"]
        else:
            msglist.append("Error fetching data from form for Degree");
            flag=-1;
        if "UserId" in HttpRequest.POST:
            UserId=HttpRequest.POST["UserId"]
        else:
            msglist.append("Error fetching data from form for UserId");
            flag=-1;
                            
        if flag==-1:
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("UserProfile/Message.html",{'mylist':msglist,})
        
        result=MarksObj.UpdateMarks(Id,SessionStart, SessionEnd, SessionNumber, SessionType, TotaMarks, SecuredMarks, TotalReappears, ReappearsRemaining, DegreeType, Board, Degree, UserId,logindetails["userid"], ip)
        msglist.append("result is %s"%result);
        return render_to_response("UserProfile/Message.html",{'mylist':msglist,})
    except Exception as inst:
        print type(inst)     # the exception instance
        print inst.args      # arguments stored in .args
        print inst           # __str__ allows args to printed directly
        x, y = inst.args
        print 'x =', x
        print 'y =', y
def MarksPostSave(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    print logindetails
    if( logindetails["userid"] == -1):
        messages.error(HttpRequest,'ERROR : Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        MarksObj=Marks()
        flag=1
        if "SessionStartMonth" in HttpRequest.POST:
            SessionStartMonth=HttpRequest.POST["SessionStartMonth"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for SessionStartMonth')
            msglist.append("Error fetching data from form for SessionStartMonth");
            flag=-1;
        if "SessionStartYear" in HttpRequest.POST:
            SessionStartYear=HttpRequest.POST["SessionStartYear"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for SessionStartYear')
            flag=-1;
        if(flag!=-1):
          SessionStart="1 "+SessionStartMonth+" "+SessionStartYear; 
        if "SessionEndMonth" in HttpRequest.POST:
            SessionEndMonth=HttpRequest.POST["SessionEndMonth"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for SessionEndMonth')
            msglist.append("Error fetching data from form for SessionEndMonth");
            flag=-1;
        if "SessionEndYear" in HttpRequest.POST:
            SessionEndYear=HttpRequest.POST["SessionEndYear"]
        else:
          messages.error(HttpRequest,'ERROR : Error fetching data from form for SessionEndYear')
          msglist.append("Error fetching data from form for SessionEndYear");
          flag=-1;
        if(flag!=-1):
          SessionEnd="1 "+SessionEndMonth+" "+SessionEndYear;
        if "SessionNumber" in HttpRequest.session:
            _SessionNumber=HttpRequest.session["SessionNumber"]
        else:
          messages.error(HttpRequest,'ERROR : Error fetching data from form for SessionNumber')
          msglist.append("Error fetching data from form for SessionNumber");
          flag=-1;
        if "SessionType" in HttpRequest.session:
            SessionType=HttpRequest.session["SessionType"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for SessionType')
            msglist.append("Error fetching data from form for SessionType");
            flag=-1;
        if "TotalMarks" in HttpRequest.POST:
            TotaMarks=HttpRequest.POST["TotalMarks"]
            if is_integer(TotaMarks):
              TotaMarks=int(TotaMarks)
            else:
              messages.error(HttpRequest,'ERROR : TotaMarks should be a number')
              msglist.append("TotaMarks should be a number");
              flag=-1;
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for TotaMarks')
              
            msglist.append("Error fetching data from form for TotaMarks");
            flag=-1;
        if "SecuredMarks" in HttpRequest.POST:
            SecuredMarks=HttpRequest.POST["SecuredMarks"]
            if is_integer(SecuredMarks):
              SecuredMarks=int(SecuredMarks)
            else:
              messages.error(HttpRequest,'ERROR : SecuredMarks should be a number')
              msglist.append("SecuredMarks should be a number");
              flag=-1;
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for SecuredMarks')
            msglist.append("Error fetching data from form for SecuredMarks");
            flag=-1;
        if "TotalReapears" in HttpRequest.POST:
            TotalReappears=HttpRequest.POST["TotalReapears"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for TotalReappears')
            msglist.append("Error fetching data from form for TotalReappears");
            flag=-1;
        if "RepearsRemaining" in HttpRequest.POST:
            ReappearsRemaining=HttpRequest.POST["RepearsRemaining"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for ReappearsRemaining')
            msglist.append("Error fetching data from form for RepearsRemaining");
            flag=-1;
        if "DegreeType" in HttpRequest.session:
            DegreeType=HttpRequest.session["DegreeType"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for DegreeType')
            msglist.append("Error fetching data from form for DegreeType");
            flag=-1;
        if "Board" in HttpRequest.POST:
            Boardid=HttpRequest.POST["Board"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for Board')
            msglist.append("Error fetching data from form for Board");
            flag=-1;
        if "Degree" in HttpRequest.session:
            _Degree=HttpRequest.session["Degree"]
        else:
            messages.error(HttpRequest,'ERROR : Error fetching data from form for Degree')
            msglist.append("Error fetching data from form for Degree");
            flag=-1;
        Boardobj=Board.objects.all();
        yearlist=range(1985,2014);
        relist=range(0,20);
        if flag==-1:
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response("UserProfile/MarksSave.html",{'BoardObject':Boardobj,'yearlist':yearlist,'relist':relist},context_instance=RequestContext(HttpRequest))
        if(modelMarks.objects.filter(SessionNumber=_SessionNumber,Degree=_Degree,UserId=logindetails["userid"]).count()==0):
          result=MarksObj.InsertMarks(SessionStart, SessionEnd, _SessionNumber, SessionType, TotaMarks, SecuredMarks, TotalReappears, ReappearsRemaining, DegreeType, Boardid, _Degree, logindetails["userid"],logindetails["userid"], ip)
        else:
          _id=modelMarks.objects.get(SessionNumber=_SessionNumber,Degree=_Degree,UserId=logindetails["userid"]).id;
          result=MarksObj.UpdateMarks(_id,SessionStart, SessionEnd, _SessionNumber, SessionType, TotaMarks, SecuredMarks, TotalReappears, ReappearsRemaining, DegreeType, Boardid, _Degree, logindetails["userid"],logindetails["userid"], ip)
        
        msglist.append("result is %s"%result);
        if(result['result']==1):
          messages.info(HttpRequest,"SUCCESS")
        else:
          messages.info(HttpRequest,"Error Occured please try again")
        return render_to_response("UserProfile/MarksSave.html",{'BoardObject':Boardobj,'yearlist':yearlist,'relist':relist},context_instance=RequestContext(HttpRequest))
    except Exception as inst:
        print type(inst)     # the exception instance
        print inst.args      # arguments stored in .args
        print inst           # __str__ allows args to printed directly
        x, y = inst.args
        print 'x =', x
        print 'y =', y
Beispiel #24
0
def CreateNewState(HttpRequest,init):
    print init
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    logindetails = GetLoginDetails(HttpRequest)
    if( logindetails["userid"] == -1):
        msglist.append('Please Login to continue')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/login/')
    try:
        name = ''
        desc = ''
        if 'EditStateCreate_Name' in HttpRequest.POST:
            name = HttpRequest.POST['EditStateCreate_Name']
            if len(name) < 1:
                msglist.append('Proper Name required')
        else:
            msglist.append('Name required')
        if 'EditStateCreate_Desc' in HttpRequest.POST:
            desc = HttpRequest.POST['EditStateCreate_Desc']
            if len(desc) < 1:
                msglist.append('Proper Desc required')
        else:
            msglist.append('Desc required')
        if len(msglist) > 0:
            msglist.append('PLEASE CORRECT THESE ERRORS')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            if ( init == 1):
                return HttpResponseRedirect('/security/init/state/create/')
            else:
                return HttpResponseRedirect('/security/state/create/')
        else:
            StatesClassObj = StateFnx()
            res = StatesClassObj.CreateState(name, desc, int(logindetails['userid']), ip)
            msglist.append('result code : %s , message %s'%(res[0],res[1]))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/security/state/')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return render_to_response("SecuritySystem/EditStates.html",{},context_instance=RequestContext(HttpRequest))
    except KeyError as msg:
        Logger_User.exception('[%s][%s] == EXCEPTION =='%('CreateNewState',ip))
        msglist.append(str(msg))
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/admin/security/states/create/')
    except:
        Logger_User.exception('[%s][%s] == EXCEPTION =='%('CreateNewState',ip))
        msglist.append('Error Occured while fetching your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        HttpResponseRedirect('/message/')