Commits

reorx  committed db046dc

getdb -> query

  • Participants
  • Parent commits 4669b7f

Comments (0)

Files changed (20)

File department/getdb.py

-from department.models import Department
-from member.models import Member
-
-def get_all():
-    return Department.objects.all()
-
-def get_dpmt_mem_all():
-    dpmt_mem_list = []
-    dpmt_list = Department.objects.all()
-    mem_list = []
-    for dpmt in dpmt_list:
-        mem_list.append(Member.objects.filter(department=dpmt.id))
-    for i in range(len(dpmt_list)):
-        dpmt_mem_list.append((dpmt_list[i], mem_list[i]))
-    return dpmt_mem_list
-
-def c_c(name):
-    check = Department.objects.filter(name=name)
-    if check:
-        status = 'already exists'
-    else:
-        _dpmt = Department(name=name)
-        _dpmt.save()
-        status = 'success'
-    return status
-
-def delete(id):
-    Department.objects.get(id=id).delete()
-    status = 'delete'
-    return status
-
-def change(id,to):
-    d = Department.objects.get(id=id)
-    d.name = to
-    d.save()
-    status = 'change'
-    return status
-

File department/query.py

+from department.models import Department
+from member.models import Member
+
+def get_all():
+    return Department.objects.all()
+
+def get_dpmt_mem_all():
+    dpmt_mem_list = []
+    dpmt_list = Department.objects.all()
+    mem_list = []
+    for dpmt in dpmt_list:
+        mem_list.append(Member.objects.filter(department=dpmt.id))
+    for i in range(len(dpmt_list)):
+        dpmt_mem_list.append((dpmt_list[i], mem_list[i]))
+    return dpmt_mem_list
+
+def c_c(name):
+    check = Department.objects.filter(name=name)
+    if check:
+        status = 'already exists'
+    else:
+        _dpmt = Department(name=name)
+        _dpmt.save()
+        status = 'success'
+    return status
+
+def delete(id):
+    Department.objects.get(id=id).delete()
+    status = 'delete'
+    return status
+
+def change(id,to):
+    d = Department.objects.get(id=id)
+    d.name = to
+    d.save()
+    status = 'change'
+    return status
+

File department/query.pyc

Binary file added.

File department/views.py

 
 from django.contrib.auth.decorators import permission_required
 
-from department import getdb as getdb_dpmt
+from department import query as query_dpmt
 
 @permission_required('duty.can_read')
 def dpmt(request):
-    list = getdb_dpmt.get_dpmt_mem_all()
+    list = query_dpmt.get_dpmt_mem_all()
     return render_to_response('dpmt/dpmt.html',{
             'dpmt_mem_list' : list,
         },
 
 @permission_required('duty.can_read')
 def dpmt_block(request):
-    list = getdb_dpmt.get_dpmt_mem_all()
+    list = query_dpmt.get_dpmt_mem_all()
     c = Context({'dpmt_mem_list' : list})
     t = get_template('dpmt/dpmt_block.html')
     return HttpResponse(t.render(c))
 @permission_required('duty.can_change')
 def add(request):
     name = request.GET.get('name')
-    status = getdb_dpmt.c_c(name)
+    status = query_dpmt.c_c(name)
     return HttpResponse(status)
 
 @permission_required('duty.can_change')
 def delete(request):
     id = request.GET.get('id')
-    status = getdb_dpmt.delete(id)
+    status = query_dpmt.delete(id)
     return HttpResponse(status)
 
 @permission_required('duty.can_change')
 def change(request):
     id = request.GET.get('id')
     to = request.GET.get('to')
-    status = getdb_dpmt.change(id,to)
+    status = query_dpmt.change(id,to)
     return HttpResponse(status)

File department/views.pyc

Binary file modified.

File duty/query/__init__.pyc

Binary file added.

File duty/query/check.pyc

Binary file added.

File duty/query/get.py

 
 from zq_onduty.Reference import fn
 
+#from zq_onduty.duty.query import check
+import check  #上句亦可
+
 import datetime,time
 date_today = datetime.date.today()
 
         return __m
 
 def get_oneweek(oneday):
-    c_c_weekarrange(oneday) #ensure week
+    check.c_c_weekarrange(oneday) #ensure week
     ###args
     mon = oneday + datetime.timedelta(days = -oneday.weekday())
     _w = Weekarrange.objects.get(startday=mon)
     week_list = []
     for i in range(7): #get week's info 
         d = mon + datetime.timedelta(days = i)
-        week_list.append(c_c_dateinfo(d,_w))
+        week_list.append(check.c_c_dateinfo(d,_w))
     mem_list = []
     for j in range(7): #get member arrange
         d = mon + datetime.timedelta(days = j)

File duty/query/get.pyc

Binary file added.

File duty/query/set.pyc

Binary file added.

File duty/views/arrange.py

 from zq_onduty.member.models import Member
 #from zq_onduty.duty import getdb as getdb_duty
 #from zq_onduty.member import getdb as getdb_member
-from zq_onduty.duty import getdb as getdb_duty
-from zq_onduty.member import getdb as getdb_member
+from zq_onduty.duty.query import get as get_duty
+from zq_onduty.duty.query import set as set_duty
+from zq_onduty.member import query as query_member
 
 from django.contrib.auth.decorators import permission_required
 
     if request.GET.get('date') == None:
         thisweek_mon = date_today + datetime.timedelta(days = -date_today.weekday())
         w = Weekarrange.objects.get(startday=thisweek_mon)
-        week_mem_list = getdb_duty.get_oneweek(date_today)
+        week_mem_list = get_duty.get_oneweek(date_today)
 
         return render_to_response('arrange/list.html',{
                 'week_mem_list' : week_mem_list,
     w = Weekarrange.objects.filter(startday=thisweek_mon)
     if w:
         w = w.get()
-        week_mem_list = getdb_duty.get_oneweek(oneday_date)
+        week_mem_list = get_duty.get_oneweek(oneday_date)
 
         t = get_template('arrange/week_block.html')
         c = Context({
 
 def next(request):
     date_ofnextweek = datetime.date.today() + datetime.timedelta(days=7)
-    week_mem_list = getdb_duty.get_oneweek(date_ofnextweek)
+    week_mem_list = get_duty.get_oneweek(date_ofnextweek)
 
     d = date_ofnextweek
     m = d + datetime.timedelta(days = -d.weekday())
 def member_select(request):
     d = request.GET.get('date')
     t = get_template('arrange/member_block.html')
-    dpmt_mem_list = getdb_member.get_mem_by_dpmt_all()
-    memShouldComeList = getdb_duty.get_mem_inarrange_oneday(d)
+    dpmt_mem_list = query_member.get_mem_by_dpmt_all()
+    memShouldComeList = get_duty.get_mem_inarrange_oneday(d)
     c = Context({
             'dpmt_mem_list':dpmt_mem_list,
             'mem_shouldcome_list':memShouldComeList,
     if mem != '': #这个是对的
         mem_list = mem.split('-')
         for memid in mem_list:
-            getdb_duty.set_duty_shouldcome(date,memid)
+            set_duty.set_duty_shouldcome(date,memid)
     ###
-    getdb_duty.set_date_shouldcome(date,mem)
+    set_duty.set_date_shouldcome(date,mem)
     return HttpResponse('arrange member success')

File duty/views/arrange.pyc

Binary file modified.

File duty/views/record.py

 
 from zq_onduty.duty.models import Dutyinfo,Dateinfo,Weekarrange
 from zq_onduty.member.models import Member
-from zq_onduty.duty import getdb as getdb_duty
-from zq_onduty.member import getdb as getdb_member
+
+from zq_onduty.duty.query import get as get_duty
 
 from django.contrib.auth.decorators import permission_required
 
 ###############################
 @permission_required('duty.can_read')
 def duty_list_main(request):
-    dateinfo_duty_thisweek_list = getdb_duty.get_dateinfo_duty_oneweek(date_today)
-    dateinfo_duty_today = getdb_duty.get_dateinfo_duty_oneday(date_today)
+    dateinfo_duty_thisweek_list = get_duty.get_dateinfo_duty_oneweek(date_today)
+    dateinfo_duty_today = get_duty.get_dateinfo_duty_oneday(date_today)
 
     return render_to_response('record/list.html',{
         'd' : dateinfo_duty_today,
 @permission_required('duty.can_read')
 def duty_list_oneweek(request):
     oneday_str = request.GET.get("date")
-    dateinfo_duty_oneweek_list = getdb_duty.get_dateinfo_duty_oneweek(oneday_str)
+    dateinfo_duty_oneweek_list = get_duty.get_dateinfo_duty_oneweek(oneday_str)
     t = get_template('record/week_block.html')
     c = Context({
         'dateinfo_duty_week_list' : dateinfo_duty_oneweek_list,
 @permission_required('duty.can_read')
 def duty_list_oneday(request):
     oneday_str = request.GET.get("date")
-    dateinfo_duty_oneday = getdb_duty.get_dateinfo_duty_oneday(oneday_str)
+    dateinfo_duty_oneday = get_duty.get_dateinfo_duty_oneday(oneday_str)
     t = get_template('record/day_block.html')
     c = Context({
         'd' : dateinfo_duty_oneday,

File duty/views/record.pyc

Binary file modified.

File home/views.py

 from member.models import Member
 from help.models import Help
 
-from duty import getdb as getdb_duty
+from duty.query import get as get_duty
+from duty.query import check as check_duty
 from duty.models import Dateinfo, Weekarrange
 import datetime
 
 
 def home(request):
     #[check Weekarrange]
-    getdb_duty.c_c_weekarrange(date_today)
+    check_duty.c_c_weekarrange(date_today)
     #end [check Weekarrange]
     check_date = Dateinfo.objects.filter(date=date_today)
     if not check_date:
             context_instance=RequestContext(request)
         )
     else:
-        member_come = getdb_duty.get_come_today()
+        member_come = get_duty.get_come_today()
         status = Dateinfo.objects.get(date=date_today)
         status = '今天是 ' + str(status.date)
         #user = request.user #instead context_instance
         )
 
 def block(request):
-    member_come = getdb_duty.get_come_today()
+    member_come = get_duty.get_come_today()
     t = get_template('home/member_block.html')
     c =  Context({ 'member_come_list' : member_come })
     return HttpResponse(t.render(c))

File home/views.pyc

Binary file modified.

File member/getdb.py

-#coding=utf-8
-from member.models import Member
-from department.models import Department
-
-def get_member_all():
-    return Member.objects.all()
-
-#yeah
-def get_member_certain(mem):
-    return Member.objects.filter(id=mem).get()
-
-def get_mem_by_dpmt_all():
-    dpmt_mem_list = []
-    dpmt_list = Department.objects.all()
-    mem_list = []
-    for dpmt in dpmt_list:
-        mem_list.append(Member.objects.filter(department=dpmt))
-    for i in range(len(dpmt_list)):
-        dpmt_mem_list.append((dpmt_list[i],mem_list[i]))
-    return dpmt_mem_list

File member/query.py

+#coding=utf-8
+from member.models import Member
+from department.models import Department
+
+def get_member_all():
+    return Member.objects.all()
+
+#yeah
+def get_member_certain(mem):
+    return Member.objects.filter(id=mem).get()
+
+def get_mem_by_dpmt_all():
+    dpmt_mem_list = []
+    dpmt_list = Department.objects.all()
+    mem_list = []
+    for dpmt in dpmt_list:
+        mem_list.append(Member.objects.filter(department=dpmt))
+    for i in range(len(dpmt_list)):
+        dpmt_mem_list.append((dpmt_list[i],mem_list[i]))
+    return dpmt_mem_list

File member/query.pyc

Binary file added.

File member/views.py

 from django.template import RequestContext
 
 from member.models import Member
-from member import getdb as getdb_member
+from member import query query_member
 from department import getdb as getdb_dpmt
 from department.models import Department
 
 def set(request):
     if "login" in request.session:
         id = request.session["login"]
-        member = getdb_member.get_member_certain(id)
+        member = query_member.get_member_certain(id)
         dpmt_list = getdb_dpmt.get_all()
         #end login session
         del request.session["login"]
 def setBackend(request):
     #[get member]
     id = request.POST.get('id')
-    member = getdb_member.get_member_certain(id)
+    member = query_member.get_member_certain(id)
     #[end]
     member.name = request.POST.get('name')
     member.password = request.POST.get('password')
 #######################
 def list(request):
     members = []
-    members = getdb_member.get_member_all()
+    members = query_member.get_member_all()
     return render_to_response('member/list.html',{
             'members' : members,
         }
     )
 
 def block(request):
-    dpmt_mem_list = getdb_member.get_mem_by_dpmt_all()
+    dpmt_mem_list = query_member.get_mem_by_dpmt_all()
     return render_to_response('member/block.html',{
             'dpmt_mem_list' : dpmt_mem_list,
         }