def forget(request): from mysite.iclock.models import Transaction from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.settings import MEDIA_ROOT request.dbapp_url = dbapp_url apps = get_all_app_and_models() request.user.iclock_url_rel = '../..' request.model = Transaction dict = checkForget() return render_to_response( 'ForgetAtt_list.html', RequestContext( request, { 'ForgetAtt_list': dumps(dict), 'from': 1, 'page': 1, 'limit': 10, 'item_count': 4, 'page_count': 1, 'iclock_url_rel': request.user.iclock_url_rel, 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'att', 'apps': apps, "myapp": [a for a in apps if a[0] == "att"][0][1], }))
def render_videolinkage_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() #searchform = get_searchform(AccLevelSet) # if searchform: # has_header=True # else: # has_header=False return render_to_response( VideoLinkagePage._template, RequestContext( request, { "app_label": "video", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0] == "video"][0][1], "menu_focus": "VideoLinkagePage", "current_app": "video", "has_header": True, #has_header, #"searchform": searchform, #"model_name": VideoLinkagePage._model_name, "position": VideoLinkagePage._position, "help_model_name": VideoLinkagePage.__name__ }))
def render_emplevelreport_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() searchform = get_searchform(request, AccLevelSet) if searchform: has_header=True else: has_header=False return render_to_response(EmpLevelReportPage._template,RequestContext(request,{ "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0]=="iaccess"][0][1], "menu_focus": "ReportFormPage", "current_app": "iaccess", "has_header": has_header, "searchform": searchform, "model_name": EmpLevelReportPage._model_name, "position": EmpLevelReportPage._position, "help_model_name": EmpLevelReportPage.__name__ }))
def render_floormng_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() searchform = get_searchform(request, Device) if searchform: has_header = True else: has_header = False is_lift = True return render_to_response( FloorMngPage._template, RequestContext( request, { "app_label": "elevator", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "current_app": "elevator", "myapp": [a for a in apps if a[0] == "elevator"][0][1], "menu_focus": "FloorSetPage", "has_header": has_header, "searchform": searchform, "position": FloorMngPage._position, "help_model_name": FloorMngPage.__name__, "is_lift": is_lift }))
def forget(request): from mysite.iclock.models import Transaction from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.settings import MEDIA_ROOT request.dbapp_url=dbapp_url apps=get_all_app_and_models() request.user.iclock_url_rel='../..' request.model = Transaction dict=checkForget() return render_to_response('ForgetAtt_list.html', RequestContext(request, {'ForgetAtt_list': dumps(dict), 'from': 1, 'page': 1, 'limit': 10, 'item_count': 4, 'page_count': 1, 'iclock_url_rel': request.user.iclock_url_rel, 'dbapp_url': dbapp_url, 'MEDIA_URL':MEDIA_ROOT, "current_app":'att', 'apps':apps, "myapp": [a for a in apps if a[0]=="att"][0][1], }))
def base_education_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() searchform = get_searchform(request, Education) if searchform: has_header = True else: has_header = False return render_to_response( EducationPage._template, RequestContext( request, { "app_label": "personnel", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0] == "personnel"][0][1], "menu_focus": "BaseDataPage", "current_app": "personnel", "model_name": EducationPage._model_name, "has_header": has_header, "searchform": searchform, "position": EducationPage._position, "help_model_name": "base_data_page" }))
def sys_option(request): from base.options import SYSPARAM from dbapp.urls import dbapp_url, surl from base import get_all_app_and_models from django.core.urlresolvers import reverse model_url = reverse(sys_option) apps = get_all_app_and_models() is_ajax = request.REQUEST.get("a", None) #if request.is_ajax():#ie6中没用 if is_ajax: return option(request, None, SYSPARAM) if request.method == 'GET': return render_to_response( 'sys_option.html', RequestContext( request, { 'surl': surl, 'dbapp_url': dbapp_url, 'MEDIA_URL': settings.MEDIA_ROOT, "current_app": 'base', 'apps': apps, 'model_url': model_url, 'menu_focus': 'sys_option', }))
def render_elevatortimeseg_page(request): #print 'lift view' from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() strtest = [a for a in apps if a[0] == "elevator"][0][1] if HasPerm(request.user, 'contenttypes.can_ElevatorTimesegSetPage'): template = ElevatorTimesegSetPage._template position = ElevatorTimesegSetPage._position searchform = get_searchform(request, AccTimeSeg) help_model_name = ElevatorTimesegSetPage.__name__ if searchform: has_header = True else: has_header = False return render_to_response( template, RequestContext( request, { "app_label": "elevator", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0] == "elevator"][0][1], "current_app": "elevator", "menu_focus": "ElevatorTimesegSetPage", "has_header": has_header, "searchform": searchform, "position": position, "help_model_name": help_model_name, }))
def funAttUerOfRun(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.att.models import USER_OF_RUN request.dbapp_url = dbapp_url apps = get_all_app_and_models() export = False export_name = USER_OF_RUN._meta.app_label + ".browse_" + USER_OF_RUN.__name__.lower( ) from mysite.personnel.models.model_emp import EmpPoPMultForeignKey from mysite.utils import GetFormField ''' 定义模型字段 ''' m_field = EmpPoPMultForeignKey(verbose_name=_(u'选择人员'), blank=True, null=True) ''' 得到表单字段供前端使用 ''' emp = GetFormField("emp", m_field) #得到表单字段 return render_to_response( 'att_USER_OF_RUN.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, 'position': _(u'考勤->排班'), "current_app": 'att', 'apps': apps, "help_model_name": "attUserOfrun", "myapp": [a for a in apps if a[0] == "att"][0][1], 'menu_focus': 'AttUserOfRun', 'export_perm': export_name, 'empfield': emp, }))
def render_rtmonitor_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() if HasPerm(request.user, 'contenttypes.can_MonitorAllPage'): template = MonitorAllPage._template position = MonitorAllPage._position help_model_name = MonitorAllPage.__name__ elif HasPerm(request.user, 'contenttypes.can_MonitorAlarmPage'): template = MonitorAlarmPage._template position = MonitorAlarmPage._position help_model_name = MonitorAlarmPage.__name__ return render_to_response(template, RequestContext(request,{ "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "current_app": "iaccess", "myapp": [a for a in apps if a[0]=="iaccess"][0][1], "app_label": "iaccess", "menu_focus": "RTMonitorPage", "position": position, "help_model_name": help_model_name }))
def render_videolinkage_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() #searchform = get_searchform(AccLevelSet) # if searchform: # has_header=True # else: # has_header=False return render_to_response(VideoLinkagePage._template,RequestContext(request,{ "app_label": "video", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0]=="video"][0][1], "menu_focus": "VideoLinkagePage", "current_app": "video", "has_header": True,#has_header, #"searchform": searchform, #"model_name": VideoLinkagePage._model_name, "position": VideoLinkagePage._position, "help_model_name": VideoLinkagePage.__name__ }))
def reportindex(request): from mysite.personnel.models.model_emp import EmpPoPMultForeignKey from mysite.urls import surl from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.utils import GetFormField empfield = EmpPoPMultForeignKey(verbose_name=_(u'人员'), blank=True) m_emp = GetFormField("emp", empfield) request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'meetingReport.html', RequestContext( request, { 'surl': surl, 'from': 1, 'page': 1, 'limit': 10, 'item_count': 4, 'page_count': 1, 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'meeting', 'position': _(u'会议->会议签到与报表'), 'apps': apps, "help_model_name": "MeetingCalculate", "myapp": [a for a in apps if a[0] == "meeting"][0][1], 'menu_focus': 'MeetingCalculate', 'perm_export': True, 'empfield': m_emp, }))
def render_doormng_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() searchform = get_searchform(request, Device) if searchform: has_header = True else: has_header = False return HttpResponseRedirect("/iaccess/DoorSetPage/") return render_to_response( DoorMngPage._template, RequestContext( request, { "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "current_app": "iaccess", "myapp": [a for a in apps if a[0] == "iaccess"][0][1], "menu_focus": "DoorSetPage", "has_header": has_header, "searchform": searchform, "position": DoorMngPage._position, "help_model_name": DoorMngPage.__name__ }))
def consumeReport(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.pos.models import CarCashSZ from mysite.settings import MEDIA_ROOT from mysite.personnel.models.model_emp import EmpMultForeignKey, EmpPoPMultForeignKey from mysite.utils import GetFormField request.dbapp_url = dbapp_url apps = get_all_app_and_models() export = True empfield = EmpPoPMultForeignKey(verbose_name=_(u'人员'), blank=True, null=False) m_emp = GetFormField("emp", empfield) return render_to_response( 'consumeReport.html', RequestContext( request, { "app_label": "pos", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "current_app": "pos", "myapp": [a for a in apps if a[0] == "pos"][0][1], "position": _(u'消费->消费报表'), #'item_list':item_list, #"model_name": consumeAppReport._model_name, "menu_focus": "consumeAppReport", "help_model_name": _(u'consume'), 'export_perm': 'export_name', 'empfield': m_emp, }))
def render_videomonitor_page(request): # from mysite.iclock.models.model_device import Device # from mysite.personnel.models import Area from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() # u = request.user # aa = u.areaadmin_set.all() # a_limit = aa and [int(a.area_id) for a in aa] or [int(area.pk) for area in Area.objects.all()]#非超级管理员且没有配置有效区域(默认全部)的有效区域id列表(即用户手动配置过用户区域的) # vod_id = request.REQUEST.get("vodid", "0") # ch = request.REQUEST.get("ch", "0") # vod_id = 5 #searchform = get_searchform(AccLevelSet) # if searchform: # has_header=True # else: # has_header=False # devices = Device.objects.filter(area__pk__in=a_limit).filter(device_type=4, id=vod_id).order_by('id').values_list('id', 'alias', 'ipaddress', 'ip_port', 'video_login', 'comm_pwd') return render_to_response( 'Vid_Monitor.html', RequestContext(request, { 'dbapp_url': dbapp_url, 'videos': "", 'ch': 1 }))
def get_content_type_list(queryset): from base import get_all_app_and_models apps=get_all_app_and_models() listTemp=[] for k,v in apps.items(): listTemp.append(u'<option class="level_0" disabled=disabled>%s</option>'%v["name"]) for ms in v["models"]: m=ms["model"] if m: ct=ContentType.objects.get_for_model(m) if ct in queryset: listTemp.append(u'<option value="%s" class="level_1">%s</option>'%(ct.pk,ms["verbose_name"])) return u'\n'.join(listTemp)
def funTestTree(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'testTree.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'iclock', 'apps': apps }))
def render_devrtmonitor_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response("Dev_RTMonitor.html",RequestContext(request,{ "app_label": "iclock", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0]=="iclock"][0][1], "current_app": "iclock",#"dev_monitor", "menu_focus": "DevRTMonitorPage", "position": _(u'设备 -> 设备监控'), "help_model_name": DevRTMonitorPage.__name__ }))
def funTestTree(request): ''' 不知道是干嘛的 ''' from dbapp.urls import dbapp_url from base import get_all_app_and_models request.dbapp_url =dbapp_url apps=get_all_app_and_models() return render_to_response('testTree.html', RequestContext(request,{ 'dbapp_url': dbapp_url, 'MEDIA_URL':MEDIA_ROOT, "current_app":'iclock', 'apps':apps }) )
def render_monitorall_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response(MonitorAllPage._template, RequestContext(request,{ "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "current_app": "iaccess", "myapp": [a for a in apps if a[0]=="iaccess"][0][1], "menu_focus": "RTMonitorPage", "position": MonitorAllPage._position, "help_model_name": MonitorAllPage.__name__ }))
def render_floorset_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() #strtest = [a for a in apps if a[0]=="elevator"][0][1] if HasPerm(request.user, 'contenttypes.can_FloorMngPage'): template = FloorMngPage._template position = FloorMngPage._position searchform = get_searchform(request, Device) help_model_name = FloorMngPage.__name__ elif HasPerm(request.user, 'contenttypes.can_FloorSetPage'): #其他跟模型相关的界面需要到模板中重定向 template = "Elevator_Floor_Set.html" position = "" searchform = "" help_model_name = "" #local variable 'searchform' referenced before assignment # else: # template = "Elevator_Floor_Set.html" # position = "" # searchform = "" if searchform: has_header = True else: has_header = False #template = "Elevator_floor_Mng.html" return render_to_response( template, RequestContext( request, { "app_label": "elevator", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0] == "elevator"][0][1], "current_app": "elevator", "menu_focus": "FloorSetPage", "has_header": has_header, "searchform": searchform, "position": position, "help_model_name": help_model_name, }))
def index(request, current_app="att", init_model=[], dataModel=None): ''' app 通用默认 index 视图 ''' from base import get_all_app_and_models from urls import dbapp_url, surl from base.models import options request.dbapp_url=dbapp_url apps=get_all_app_and_models() # -----------第一次执行 if current_app=='worktable': #-------------------------------------------------- worktable 视图的特殊处理 from django.conf import settings installed_language=settings.APP_CONFIG.language.language return render_to_response("worktable.html",{},RequestContext(request, { "apps":apps, "current_app":current_app, 'app_name': dataModel and (hasattr(dataModel.Admin, "app_menu") and dataModel.Admin.app_menu or dataModel._meta.app_label) or "", "init_model": init_model or "", "dbapp_url": dbapp_url, "installed_language":installed_language})) else: opt=current_app+"."+current_app+"_default_page" model_name=options[opt] if model_name: redirect_url="/"+surl+model_name url_list=redirect_url.split("/") if request.user.has_perm("%s.browse_%s"%(url_list[-3],url_list[-2].lower())): return HttpResponseRedirect(redirect_url) elif request.user.has_perm("contenttypes.can_%s"%(url_list[-2])): return HttpResponseRedirect(redirect_url) default_model=[m for m in dict(apps)[current_app]["models"] if (not m.has_key("parent_model"))] if len(default_model)!=0: url="" if default_model[0]["model"]: if request.user.has_perm("%s.browse_%s"%(default_model[0]["model"]._meta.app_label,default_model[0]["model"].__name__.lower())): url=dbapp_url+default_model[0]["model"]._meta.app_label+"/"+default_model[0]["name"]+"/" return HttpResponseRedirect(url) else: return render_to_response('no_permission_info.html',RequestContext(request,{})) else: if request.user.has_perm("contenttypes.can_%s"%default_model[0]["operation"].__name__): url="/"+surl+default_model[0]["url"][1:]#reverse函数返回的url是从根目录开始的,带了"/" return HttpResponseRedirect(url) else: return render_to_response('no_permission_info.html',RequestContext(request,{})) else: return render_to_response('no_permission_info.html',RequestContext(request,{}))
def get_content_type_list(queryset): from base import get_all_app_and_models apps = get_all_app_and_models() listTemp = [] for k, v in apps.items(): listTemp.append( u'<option class="level_0" disabled=disabled>%s</option>' % v["name"]) for ms in v["models"]: m = ms["model"] if m: ct = ContentType.objects.get_for_model(m) if ct in queryset: listTemp.append( u'<option value="%s" class="level_1">%s</option>' % (ct.pk, ms["verbose_name"])) return u'\n'.join(listTemp)
def render_reportform_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() if HasPerm(request.user, 'contenttypes.can_AllEventReportPage'): model_name = AllEventReportPage._model_name template = AllEventReportPage._template position = AllEventReportPage._position searchform = get_searchform(request, AccRTMonitor) help_model_name = "AllEventReportPage" elif HasPerm(request.user, 'contenttypes.can_AlarmEventReportPage'): model_name = AlarmEventReportPage._model_name template = AlarmEventReportPage._template position = AlarmEventReportPage._position searchform = get_searchform(request, AccRTMonitor) help_model_name = "AllEventReportPage" elif HasPerm(request.user, 'contenttypes.can_EmpLevelReportPage'): model_name = EmpLevelReportPage._model_name template = EmpLevelReportPage._template position = EmpLevelReportPage._position searchform = get_searchform(request, AccLevelSet) help_model_name = "AllEventReportPage" if searchform: has_header = True else: has_header = False return render_to_response( template, RequestContext( request, { "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "model_name": model_name, "current_app": "iaccess", "myapp": [a for a in apps if a[0] == "iaccess"][0][1], "menu_focus": "ReportFormPage", "has_header": has_header, "searchform": searchform, "position": position, "help_model_name": help_model_name }))
def funPosGuide(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'pos_guide.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'pos', 'apps': apps, "myapp": [a for a in apps if a[0] == "pos"][0][1], 'app_label': 'pos', 'menu_focus': 'pos_guide', 'position': _(u'消费->导航'), }))
def render_electromap_page(request): from dbapp.urls import dbapp_url #logid = request.GET.get("a_logid", 0)#直接访问监控报警时从0开始 request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response(ElectroMapPage._template, RequestContext(request,{ "app_label": "iaccess", "menu_focus": "RTMonitorPage", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0]=="iaccess"][0][1], "current_app": "iaccess", #"logid": logid, "position": ElectroMapPage._position, "help_model_name": ElectroMapPage.__name__, }))
def render_reportform_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() if HasPerm(request.user, 'contenttypes.can_AllEventReportPage'): model_name = AllEventReportPage._model_name template = AllEventReportPage._template position = AllEventReportPage._position searchform = get_searchform(request, AccRTMonitor) help_model_name = AllEventReportPage.__name__ elif HasPerm(request.user, 'contenttypes.can_AlarmEventReportPage'): model_name = AlarmEventReportPage._model_name template = AlarmEventReportPage._template position = AlarmEventReportPage._position searchform = get_searchform(request, AccRTMonitor) help_model_name = AlarmEventReportPage.__name__ elif HasPerm(request.user, 'contenttypes.can_EmpLevelReportPage'): model_name = EmpLevelReportPage._model_name template = EmpLevelReportPage._template position = EmpLevelReportPage._position searchform = get_searchform(request, AccLevelSet) help_model_name = EmpLevelReportPage.__name__ if searchform: has_header = True else: has_header = False return render_to_response(template, RequestContext(request,{ "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "model_name": model_name, "current_app": "iaccess", "myapp": [a for a in apps if a[0]=="iaccess"][0][1], "menu_focus": "ReportFormPage", "has_header": has_header, "searchform": searchform, "position": position, "help_model_name": help_model_name }))
def render_acc_guide_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'Acc_Guide.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, 'current_app': 'iaccess', 'apps': apps, 'help_model_name': "AccGuidePage", 'myapp': [a for a in apps if a[0] == "iaccess"][0][1], 'app_label': 'iaccess', 'model_name': 'AccGuidePage', 'menu_focus': 'AccGuidePage', 'position': _(u'门禁系统->导航'), }))
def funPosDeviceDataManage(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'pos_DeviceDataManage.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'pos', 'apps': apps, "help_model_name": "DeviceDataManage", "myapp": [a for a in apps if a[0] == "pos"][0][1], 'app_label': 'pos', 'model_name': 'Device', 'menu_focus': 'PosDeviceDataManage', 'position': _(u'消费->消费设备管理'), }))
def funAttGuide(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'att_guide.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'att', 'apps': apps, "help_model_name": "AttGuide", "myapp": [a for a in apps if a[0] == "att"][0][1], 'app_label': 'att', 'model_name': 'AttGuide', 'menu_focus': 'AttGuide', 'position': _(u'考勤->导航'), }))
def render_empelevatorlevelset_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() if HasPerm(request.user, 'contenttypes.can_EmpElevtorLevelByLevelPage'): model_name = EmpElevtorLevelByLevelPage._model_name template = EmpElevtorLevelByLevelPage._template position = EmpElevtorLevelByLevelPage._position searchform = get_searchform(request, AccLevelSet) help_model_name = EmpElevtorLevelByLevelPage.__name__ elif HasPerm(request.user, 'contenttypes.can_EmpElevatorLevelByEmpPage'): model_name = EmpElevatorLevelByEmpPage._model_name template = EmpElevatorLevelByEmpPage._template position = EmpElevatorLevelByEmpPage._position searchform = get_searchform(request, Employee) help_model_name = EmpElevatorLevelByEmpPage.__name__ if searchform: has_header = True else: has_header = False return render_to_response( template, RequestContext( request, { "app_label": "elevator", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "current_app": "elevator", "myapp": [a for a in apps if a[0] == "elevator"][0][1], "menu_focus": "EmpElevatorLevelSetPage", "has_header": has_header, "searchform": searchform, "position": position, "model_name": model_name, "help_model_name": help_model_name }))
def render_videomonitor_page(request): # from mysite.iclock.models.model_device import Device # from mysite.personnel.models import Area from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() # u = request.user # aa = u.areaadmin_set.all() # a_limit = aa and [int(a.area_id) for a in aa] or [int(area.pk) for area in Area.objects.all()]#非超级管理员且没有配置有效区域(默认全部)的有效区域id列表(即用户手动配置过用户区域的) # vod_id = request.REQUEST.get("vodid", "0") # ch = request.REQUEST.get("ch", "0") # vod_id = 5 #searchform = get_searchform(AccLevelSet) # if searchform: # has_header=True # else: # has_header=False # devices = Device.objects.filter(area__pk__in=a_limit).filter(device_type=4, id=vod_id).order_by('id').values_list('id', 'alias', 'ipaddress', 'ip_port', 'video_login', 'comm_pwd') return render_to_response('Vid_Monitor.html',RequestContext(request,{'dbapp_url': dbapp_url, 'videos': "", 'ch': 1}))
def render_doorset_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() if HasPerm(request.user, 'contenttypes.can_DoorMngPage'): template = DoorMngPage._template position = DoorMngPage._position searchform = get_searchform(request, Device) help_model_name = DoorMngPage.__name__ elif HasPerm(request.user, 'contenttypes.can_DoorSetPage'):#其他跟模型相关的界面需要到模板中重定向 template = "Acc_Door_Set.html" position = "" searchform = "" help_model_name = "" #local variable 'searchform' referenced before assignment # else: # template = "Acc_Door_Set.html" # position = "" # searchform = "" if searchform: has_header=True else: has_header=False return render_to_response(template, RequestContext(request, { "app_label": "iaccess", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0]=="iaccess"][0][1], "current_app": "iaccess", "menu_focus": "DoorSetPage", "has_header": has_header, "searchform": searchform, "position": position, "help_model_name": help_model_name, }))
def reportindex(request): ''' 考勤计算与报表 ''' from mysite.urls import surl from dbapp.urls import dbapp_url from base import get_all_app_and_models request.user.iclock_url_rel = '../..' request.model = Transaction unit = GetCalcUnit() symbol = GetCalcSymbol() dc = {} dc['unit'] = unit dc['symbol'] = symbol request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( 'calculateReport.html', RequestContext( request, { 'latest_item_list': smart_str(dumps(dc)), 'surl': surl, 'from': 1, 'page': 1, 'limit': 10, 'item_count': 4, 'page_count': 1, 'iclock_url_rel': request.user.iclock_url_rel, 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'att', 'position': _(u'考勤->考勤计算与报表'), 'apps': apps, "help_model_name": "AttCalculate", "myapp": [a for a in apps if a[0] == "att"][0][1], 'menu_focus': 'AttCalculate', 'perm_export': True, }))
def funAttDeviceUserManage(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.personnel.models.model_area import Area request.dbapp_url =dbapp_url apps=get_all_app_and_models() if hasattr(Area,"get_all_operation_js"): actions=Area.get_all_operation_js(request.user) return render_to_response('att_DeviceUSERManage.html', RequestContext(request,{ 'dbapp_url': dbapp_url, 'MEDIA_URL':MEDIA_ROOT, "current_app":'att', 'apps':apps, "help_model_name":"DeviceUserManage", "myapp": [a for a in apps if a[0]=="att"][0][1], 'specific_actions':actions, 'menu_focus':'AttDeviceUserManage', 'position':_(u'考勤->区域用户管理'), }) )
def funAttUerOfRun(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.att.models import USER_OF_RUN request.dbapp_url=dbapp_url apps=get_all_app_and_models() export=False export_name=USER_OF_RUN._meta.app_label+".dataexport_"+USER_OF_RUN.__name__.lower() return render_to_response('att_USER_OF_RUN.html', RequestContext(request,{ 'dbapp_url': dbapp_url, 'MEDIA_URL':MEDIA_ROOT, 'position':_(u'考勤->员工排班'), "current_app":'att', 'apps':apps, "help_model_name":"attUserOfrun", "myapp": [a for a in apps if a[0]=="att"][0][1], 'menu_focus':'AttUserOfRun', 'export_perm':export_name, }) )
def render_batchtime_Page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() searchform = get_searchform(request, BatchTime) if searchform: has_header = True else: has_header = False try: ct = ContentType.objects.get_for_model(BatchTime) log_search = "content_type__id=%s" % ct.pk except: log_search = "" if get_option("POS_IC"): help_model_name = "ic_batchtimepage" else: help_model_name = BatchTimePage.__name__ return render_to_response( BatchTimePage._template, RequestContext( request, { "app_label": "pos", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0] == "pos"][0][1], "menu_focus": "PosFormPage", "current_app": "pos", "model_name": BatchTimePage._model_name, "has_header": has_header, "searchform": searchform, "position": BatchTimePage._position, "help_model_name": help_model_name, "log_search": log_search }))
def funAttDeviceUserManage(request): from dbapp.urls import dbapp_url from base import get_all_app_and_models from mysite.personnel.models.model_area import Area request.dbapp_url = dbapp_url apps = get_all_app_and_models() if hasattr(Area, "get_all_operation_js"): actions = Area.get_all_operation_js(request.user) return render_to_response( 'att_DeviceUSERManage.html', RequestContext( request, { 'dbapp_url': dbapp_url, 'MEDIA_URL': MEDIA_ROOT, "current_app": 'att', 'apps': apps, "help_model_name": "DeviceUserManage", "myapp": [a for a in apps if a[0] == "att"][0][1], 'specific_actions': actions, 'menu_focus': 'AttDeviceUserManage', 'position': _(u'考勤->区域用户'), }))
def sys_option(request): from base.options import SYSPARAM from dbapp.urls import dbapp_url, surl from base import get_all_app_and_models from django.core.urlresolvers import reverse model_url=reverse(sys_option) apps=get_all_app_and_models() is_ajax=request.REQUEST.get("a",None) #if request.is_ajax():#ie6中没用 if is_ajax: return option(request,None,SYSPARAM) if request.method=='GET': return render_to_response('sys_option.html', RequestContext(request, { 'surl': surl, 'dbapp_url': dbapp_url, 'MEDIA_URL': settings.MEDIA_ROOT, "current_app":'base', 'apps':apps, 'model_url':model_url, 'menu_focus':'sys_option', }))
def render_visitor_level_set_page(request): from dbapp.urls import dbapp_url request.dbapp_url = dbapp_url apps = get_all_app_and_models() return render_to_response( VisitorLevelSetPage._template, RequestContext( request, { "app_label": "visitor", "dbapp_url": dbapp_url, "MEDIA_ROOT": MEDIA_ROOT, "apps": apps, "myapp": [a for a in apps if a[0] == "visitor"][0][1], "menu_focus": "VisitorLevelSetPage", "current_app": "visitor", "has_header": True, #"searchform": False, #"model_name": VisitorLevelSetPage._model_name, "position": VisitorLevelSetPage._position, "help_model_name": VisitorLevelSetPage.__name__ }))
def reportindex(request): ''' 考勤计算与报表 ''' from mysite.urls import surl from dbapp.urls import dbapp_url from base import get_all_app_and_models request.user.iclock_url_rel='../..' request.model = Transaction unit=GetCalcUnit() symbol=GetCalcSymbol() dc={} dc['unit']=unit dc['symbol']=symbol request.dbapp_url=dbapp_url apps=get_all_app_and_models() return render_to_response('calculateReport.html', RequestContext(request, {'latest_item_list': smart_str(dumps(dc)), 'surl': surl, 'from': 1, 'page': 1, 'limit': 10, 'item_count': 4, 'page_count': 1, 'iclock_url_rel': request.user.iclock_url_rel, 'dbapp_url': dbapp_url, 'MEDIA_URL':MEDIA_ROOT, "current_app":'att', 'position':_(u'考勤->考勤计算与报表'), 'apps':apps, "help_model_name":"AttCalculate", "myapp": [a for a in apps if a[0]=="att"][0][1], 'menu_focus':'AttCalculate', 'perm_export':True, }))
def model_data_list(request, dataModel, qs=None, model_url=None): ''' 通用列表视图 ''' # if qs: # print 'qs-----------------------------------:',qs from urls import dbapp_url, surl from dbapp.data_utils import exist_perm from data_edit import form_for_model from dbapp.viewmodels import get_all_view lng=get_language() # 获取语言 action=request.REQUEST.get(ACTION_VAR, "") # 获取动作类型 if len(action)>0: checkAction=action if not hasPerm(request.user, dataModel, checkAction): # 动作权限的判断 return getJSResponse(u"{ errorCode:-2,errorInfo:\"%s\"}"%_(u"你没有该权限!")) # 返回 js 内容 resp=doAction(action, request, dataModel) if resp: return resp ##################### 判断是否有 default_give_perms 权限 ############################ if not hasPerm(request.user, dataModel, "browse"): # 没有 browse 权限 模型是否有default_give_perms项 if hasattr(dataModel.Admin,"default_give_perms") and dataModel.Admin.default_give_perms: flag=False for perm in dataModel.Admin.default_give_perms: if request.user.has_perm(perm): flag=True break if not flag: if request.is_ajax(): return HttpResponse("session_fail_or_no_permission") else: return render_to_response('no_permission_info.html',RequestContext(request,{'dbapp_url': dbapp_url})) else: if request.is_ajax(): return HttpResponse("session_fail_or_no_permission") else: return render_to_response('no_permission_info.html',RequestContext(request,{'dbapp_url': dbapp_url})) master=get_model_master(dataModel) request.model=dataModel request.dbapp_url=dbapp_url #已经加到中间件中了 /data/ # 取缓存 cache_key="%s_%s_cc"%(lng,dataModel.__name__) # zh-cn_model_1_cc cache_cc=cache.get(cache_key) if not cache_cc: searchform="" if hasattr(dataModel.Admin,"query_fields") and dataModel.Admin.query_fields: searchform=seachform_for_model(request,dataModel,fields=list(dataModel.Admin.query_fields)) # 查询表单html内容 cache_cc={ 'title': (u"%s"%dataModel._meta.verbose_name).capitalize(), 'app_label':dataModel._meta.app_label, 'model_name':dataModel.__name__, 'dbapp_url': dbapp_url, 'model_url': model_url or request.dbapp_url+dataModel._meta.app_label+"/"+dataModel.__name__+"/", 'searchform':searchform, 'import_perm':dataModel._meta.app_label+".dataimport_"+dataModel.__name__.lower(), # 导入标识名 'export_perm':dataModel._meta.app_label+".dataexport_"+dataModel.__name__.lower(), # 导出标识名 'menu_focus':hasattr(dataModel.Admin, "menu_focus") and dataModel.Admin.menu_focus or dataModel.__name__, #用于跟模型相关的菜单获取焦点 'position':hasattr(dataModel.Admin, "position") and dataModel.Admin.position or None, } cache.set(cache_key,cache_cc,60*60*24*7) # 参数字典 加入缓存 ####################### 得到分页和排序参数字典 这些参数不缓存 ##################### qs, cl=QueryData(request, dataModel, master, qs) # 模型数据查询 try: offset = int(request.REQUEST.get(PAGE_VAR, 1)) except: offset=1 limit= int(request.REQUEST.get(PAGE_LIMIT_VAR, settings.PAGE_LIMIT)) try: mnp=int(request.REQUEST.get(MAX_NO_PAGE, 50)) if qs.count()<=mnp: limit=mnp except: limit=50 cc={ 'from': (offset-1)*limit+1, 'page': offset, 'limit': limit, 'cl': cl, } cc.update(cache_cc) # 合并前面的参数字典 isProcessed=False for ret in on_list_paginator.send(sender=cc, request=request, dataModel=dataModel, querySet=qs): if ret[1]: isProcessed=True break if not isProcessed: paginator = Paginator(qs, limit) # django 的分页对象 item_count = paginator.count if offset>paginator.num_pages: offset=paginator.num_pages cc['page']=offset if offset<1: offset=1 pgList = paginator.page(offset) cc['latest_item_list']=pgList.object_list # 分页结果数据 cc['page_count']=paginator.num_pages cc['item_count']=item_count list_exception_fields=request.REQUEST.getlist("exception_fields") list_addition_fields=request.REQUEST.getlist("addition_fields") if master: master2str=master.name else: master2str="" cache_key=lng+"_"+dataModel.__name__+"_".join(list_exception_fields+list_addition_fields)+master2str t=cache.get(cache_key) # 缓存 DefaultJsonDataTemplate if not t: t=getDefaultJsonDataTemplate(dataModel,list_exception_fields,list_addition_fields,master) cache.set(cache_key,t,60*60*24*7) var_options=u"""record_count:{{ item_count }}, item_from:{{ from }}, current_page:{{ page }}, page_limit:{{ limit }}, page_count:{{ page_count }}, order_by:"{{ order_by }}", 'options':%s, 'actions':%s """%getUsrCreateFrameOptions(dataModel,request) # 得到Options集合信息 t="{ \n "+t+var_options+" \n }" t_r=Template(t).render(RequestContext(request, cc)) #---------------------------------一部分内容 if request.method=='POST': # 如果是ajax请求------------------------------------------------------------------------------------------如“日志记录” return getJSResponse(smart_str(t_r)) from urls import get_model_data_url from base import get_all_app_and_models import base if issubclass(dataModel, base.models.CachingModel) and dataModel.Admin.log: try: ct=ContentType.objects.get_for_model(dataModel) cc['log_url']=get_model_data_url(base.models.LogEntry)+("?content_type__id=%s"%ct.pk) cc['log_search']="content_type__id=%s"%ct.pk except: print_exc() apps=get_all_app_and_models() cc["apps"]=apps admin=hasattr(dataModel, "Admin") and dataModel.Admin or None current_app=hasattr(admin, "app_menu") and admin.app_menu or dataModel._meta.app_label cc["current_app"]=current_app try: cc["myapp"]=[a for a in apps if a[0]==current_app][0][1] # 所在app的所有信息 except: pass cache_key="%s_%s_template"%(lng,dataModel.__name__) tmp_file=cache.get(cache_key) if not tmp_file: tmp_file=loader.select_template([ dataModel._meta.app_label+"."+dataModel.__name__+".html", dataModel.__name__+"_list.html", "data_list_"+dataModel._meta.app_label+".html", "data_list.html"]) #cache.set(cache_key,tmp_file,60*60*24*7) cc["query"]="&".join([k+"="+v[0] for k,v in dict(request.GET).items()]) # 查询参数 cc['datalist']=smart_str(t_r) # 主要数据 return HttpResponse(tmp_file.render(RequestContext(request, cc)))