Пример #1
0
def ListMenu(HttpRequest,req_type):
    msglist = AppendMessageList(HttpRequest)
    menuobj = MenuFnx()
    menu = menuobj.getAllMenu()
    if len(menu) == 0 :
        msglist.append('No Menu items exist in the system')
    return render_to_response('txadmin/ListMenu.html',{'title':'list menu','menulist':menu,'msglist':msglist},context_instance=RequestContext(HttpRequest))
Пример #2
0
def index_edit(request,menuid):
    menuobj = MenuFnx()
    msglist = AppendMessageList(HttpRequest)
    p = menuobj.getSingleMenuItemById(menuid)
    if( len(p) == 0 ):
        msglist.append('could not fetch menu details. Please try after sometime')
    parentmenu = menuobj.getParentMenus()
    if ( len(parentmenu) == 0 ):
        msglist.append('There are no parent menu items yet')
    return render_to_response('txadmin/CreateMenu.html',{'title':'create menu','par':parentmenu,'msglist':msglist},context_instance=RequestContext(request))
Пример #3
0
def CreatePermissionIndex(HttpRequest):
    ip = HttpRequest.META['REMOTE_ADDR']
    msglist = AppendMessageList(HttpRequest)
    try:
        return render_to_response('security/states/EditPermission.html',{'visible_list':'false','visible_create':'true',},context_instance=RequestContext(HttpRequest))
    except:
        LoggerMisc.exception('[%s] EXCEPTION ip = %s'%('CreatePermissionIndex',ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
Пример #4
0
def AddUserContact(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        pass
    except:
        LoggerUser.exception('[AddUserContact][%s]exception message'%(ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
Пример #5
0
def EditUserContactIndex(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        userid = getUserId(HttpRequest)
        if( userid[0] != 1):
            LoggerUser.error('[%s] %s'%('ListUserContact',userid[1]))
            msglist.append(userid[1])
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/user/login/')
        else:
            userid = userid[1]
            UserContactObj = UserContactFnx()
            result = UserContactObj.getUserContactObjectByUserid(userid)
            if result[0] != 1:
                LoggerUser.error('[%s] %s'%('ListUserContact',result[1]))
                msglist.append(result[1])
                HttpRequest.session[SESSION_MESSAGE] = msglist
                return HttpResponseRedirect('/message/')
            ContactInfo = result[1]
            if ContactInfo is None:
                msglist.append('No contact information for this user could be found. Please user add contact page to add some details first')
            LoggerUser.debug('[%s] userid=%s, details=%s'%('ListUserContact',userid,ContactInfo))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response('ProfileSystem/UserContact/EditUserContact.html',{"readonly":"false","ContactInfo":ContactInfo},context_instance=RequestContext(HttpRequest))

    except:
        LoggerUser.exception('[EditUserContactIndex][%s]exception message'%(ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
Пример #6
0
def CreateGroup_Index(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return render_to_response('UserSystem/GROUP/CreateGroup.html',{},context_instance=RequestContext(HttpRequest))
    except:
        LoggerUser.exception('[CreateGroup_Index][%s]exception message'%(ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/error/')
Пример #7
0
def CreateMenuFromSite_Index(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        menuobj = MenuFnx()
        parentmenu = menuobj.getParentMenus()
        if ( parentmenu[0] == 1 ):
            menulist = parentmenu[1]
            if( len(menulist) == 0):
                msglist.append('There are no parent menu items yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response('UserSystem/menu/CreateMenu.html',{'title':'create menu','par_menu':menulist},context_instance=RequestContext(HttpRequest))
        else:
            LoggerUser.error("ERROR: " + parentmenu[1])
            msglist.append("ERROR: " + parentmenu[1])
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/error/')
    except:
        LoggerUser.exception('[MenuCreate_Index][%s]exception message'%(ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/error/')
Пример #8
0
def ListContentTypePermissions(HttpRequest,cid):
    ip = HttpRequest.META['REMOTE_ADDR']
    msglist = AppendMessageList(HttpRequest)
    try:
        permobj = PermissionsClass()
        permlist = permobj.getAllPermissionsForAContentTypeByID(cid)
        if permlist[0] == 1:
            permlist = permlist[1]
            if len(permlist) == 0:
                msglist.append('There are no permissions defined for this content type yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response('security/permissions/EditPermission.html',{'permlist':permlist,'visible_list':'true','visible_create':'false',},context_instance=RequestContext(HttpRequest))
        else:
            LoggerMisc.error('[%s] ip = %s'%('ListPermission',ip))
            msglist.append('[ERROR][ListContentTypePermissions] %s'%(permlist[1]))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/message/')
    except:
        LoggerMisc.exception('[%s] EXCEPTION ip = %s'%('ListContentTypePermissions',ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
Пример #9
0
def EditGroupMenu(HttpRequest,gid):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        selected_menu = HttpRequest.POST.getlist('CheckBox_EditGroupMenuOptions')
        LoggerUser.debug('[EditGroupMenu] selected menu is %s'%(selected_menu)) 
        groupmenu_obj = GroupMenuFunctions()
        result =  groupmenu_obj.CreateGroupMenu(gid, selected_menu, 1, 'test')
        if( result[0] != -1):
            msglist.append("SUCCESS" + str(result))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/user/group/list/all/')
        else:
            LoggerUser.error('[EditGroupMenu][%s]error message for gid %s, msg = %s'%(ip,gid,result[1]))
            msglist.append(result[1])
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/error/')
    except:
        LoggerUser.exception('[EditGroupMenu][%s]exception message for gid %s'%(ip,gid))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/error/')
Пример #10
0
def ListGroupMenu_Index(HttpRequest,gid):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        groupmenu_obj = GroupMenuFunctions()
        menulist = groupmenu_obj.GetAllMenuObjectsByGroupid(gid)
        if(menulist[0] == 1):
            menulist = menulist[1]
            if(  len(menulist) == 0 ):
                msglist.append('There are no menu items assigned to this group yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response('UserSystem/GroupMenu/ListGroupMenu.html',{'groupmenulist':menulist},context_instance=RequestContext(HttpRequest))
        else:
            LoggerUser.error("ERROR: " + menulist[1])
            msglist.append("ERROR: " + menulist[1])
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/error/')
    except:
        LoggerUser.exception('[ListGroupMenu_Index][%s]exception message for gid %s'%(ip,gid))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/error/')
Пример #11
0
def EditContentTypes(HttpRequest):
    ip = HttpRequest.META['REMOTE_ADDR']
    msglist = AppendMessageList(HttpRequest)
    try:
        ctobj = ContentTypeClass()
        ctlist = ctobj.getAllContentTypes()
        if ctlist[0] == 1:
            ctlist = ctlist[1]
            if len(ctlist) == 0:
                msglist.append('There are no content types defined yet')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return render_to_response('security/contenttypes/ContentType.html',{'ctlist':ctlist,'can_edit':'true',},context_instance=RequestContext(HttpRequest))
        else:
            LoggerMisc.error('[%s] ip = %s'%('ListContentTypes',ip))
            msglist.append('[ERROR][ListContentTypes] %s'%(ctlist[1]))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/message/')
    except:
        LoggerMisc.exception('[%s] EXCEPTION ip = %s'%('ListContentTypes',ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
Пример #12
0
def ListGroups(HttpRequest, req_type):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        
        if req_type == "all":
            group = GroupFnx()
            grouplist = group.ListAllGroups()
            if( grouplist[0] == 1 ):
                grouplist = grouplist[1]
                if ( len(grouplist) == 0):
                        msglist.append("THERE NO GROUPS IN THE SYSTEM, YET")
                HttpRequest.session[SESSION_MESSAGE] = msglist
                return render_to_response('UserSystem/GROUP/ListGroups.html',{'grouplist':grouplist},context_instance=RequestContext(HttpRequest))
            else:
                LoggerUser.error('[%s] req_type = %s, return code = %s, ip = %s'%('ListGroups',req_type,str(grouplist),ip))
                msglist.append('[ERROR][ListGroups] %s'%(grouplist[1]))
                HttpRequest.session[SESSION_MESSAGE] = msglist
                return HttpResponseRedirect('/error/')
    except:
        LoggerUser.exception('[%s] req_type = %s, ip = %s'%('ListGroups',req_type,ip))
        msglist.append('Some error has occoured while processing your request')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/error/')
Пример #13
0
def CreateMenuFromSite(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    menuobj = MenuFnx()
    ip = HttpRequest.META['REMOTE_ADDR']
    parentmenu = menuobj.getParentMenus()
    if ( parentmenu[0] == -1 ):
            msglist.append("ERROR: " + parentmenu[1])
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/error/')
    try:
        strval = StringValidate()
        menuname = HttpRequest.POST['CreateMenu_name']
        #if( strval.validate_alphanumstring( menuname) != 1 ):
        #    msglist.append('Error in menuname')
        menudesc = HttpRequest.POST['CreateMenu_desc']
        #if( strval.validate_alphanumstring( menudesc) != 1 ):
        #    msglist.append('Error in menudesc')
        menuurl = HttpRequest.POST['CreateMenu_url']
        #if( strval.validate_alphanumstring( menuurl) != 1 ):
        #    msglist.append('Error in menuurl')
        #menuicon = HttpRequest.POST['CreateMenu_micon']
        #if( strval.validate_alphastring( menuicon) != 1 ):
        #    errorlist.append('Error in menuicon')
        menuicon = 'NULL'
        menupid = -1
        if( len(parentmenu[1]) == 0 ):
            menupid = -1
        else:
            menupid  = HttpRequest.POST['CreateMenu_parmenu']
        if len(msglist) > 0:
            msglist.append('PLEASE CORRECT THESE ERRORS')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/user/menu/create/')
        else:
            res = menuobj.CreateMenuFromSite(menuname, menudesc, menuurl, menupid, menuicon,1,HttpRequest.META['REMOTE_ADDR'])
            msglist.append('result code : %s , message %s'%(res[0],res[1]))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/user/menu/create/')
    except KeyError as msg:
        LoggerUser.exception('[CreateMenuFromSite][%s]exception message'%(ip))
        msglist.append(str(msg))
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/menu/create/')    
    except:
        LoggerUser.exception('[CreateMenuFromSite][%s]exception message'%(ip))
        msglist.append('exception happened in create menu function')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/menu/create/')
Пример #14
0
def CreatePermission(HttpRequest):
    ip = HttpRequest.META['REMOTE_ADDR']
    msglist = AppendMessageList(HttpRequest)
    try:
        name = ''
        desc = ''
        if 'EditState_Create_Name' in HttpRequest.POST:
            name = HttpRequest.POST['EditState_Create_Name']
            if len(name) < 4:
                msglist.append('Proper Name required')
        else:
            msglist.append('Name required')
        if 'EditState_Create_Desc' in HttpRequest.POST:
            desc = HttpRequest.POST['EditState_Create_Desc']
            if len(desc) < 4:
                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
            return HttpResponseRedirect('/admin/security/states/create/')
        else:
            PermClassObj = PermissionsClass()
            res = PermClassObj.CreatePermission(name, desc, 1, ip)
            msglist.append('result code : %s , message %s'%(res[0],res[1]))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/admin/security/contenttypes/')
    except KeyError as msg:
        LoggerMisc.exception('[CreateGroup][%s]exception message'%(ip))
        msglist.append(str(msg))
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/admin/security/perms/create/')
    except:
        LoggerMisc.exception('[CreateGroup][%s]exception message'%(ip))
        msglist.append('exception happened in create group function')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/message/')
Пример #15
0
def CreateGroup(HttpRequest):
    msglist = AppendMessageList(HttpRequest)
    ip = HttpRequest.META['REMOTE_ADDR']
    try:
        gname = HttpRequest.POST['Group_Name']
        if gname is None:
            msglist.append("ERROR : group name is required")
        gdesc = HttpRequest.POST['Group_Desc']
        if gdesc is None:
                msglist.append("ERROR: group desc is required")
        if len(msglist) > 0:
            msglist.append('PLEASE CORRECT THESE ERRORS')
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/user/group/create/')
        else:
            group_obj = GroupFnx()
            res = group_obj.CreateGroup(gname, gdesc, 1, 'system', 1, ip)
            msglist.append('result code : %s , message %s'%(res[0],res[1]))
            HttpRequest.session[SESSION_MESSAGE] = msglist
            return HttpResponseRedirect('/user/group/create/')
    except KeyError as msg:
        LoggerUser.exception('[CreateGroup][%s]exception message'%(ip))
        msglist.append(str(msg))
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/group/create/')  
    except:
        LoggerUser.exception('[CreateGroup][%s]exception message'%(ip))
        msglist.append('exception happened in create group function')
        HttpRequest.session[SESSION_MESSAGE] = msglist
        return HttpResponseRedirect('/user/group/create/')