def grade(request): """ 年级管理页面 """ serch_value_list = ['name', 'enable'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = Grade.objects.count() page_obj = Pagefunc(current_page, all_count, url='myadmin/grade_manage') qs_obj = Grade.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: if i == 'name': new_serch_dict[i] = serch_dict[i] else: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/grade_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'serch_dict': new_serch_dict })
def feedback(request): """ 问题反馈 """ serch_value_list = ['user__userid'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] user_obj = User.objects.all() all_count = Feedback.objects.count() page_obj = Pagefunc( current_page, all_count, url='myadmin/feedback', ) qs_obj = Feedback.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] return render(request, 'myadmin/feedback.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'user_obj': user_obj })
def appointment(request): """ 一对一预约 """ serch_value_list = [ 'teacher__teacher_name', 'user__userid', ] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] user_obj = User.objects.all() teacher_obj = TeacherInfo.objects.all() all_count = OneToOne.objects.count() page_obj = Pagefunc( current_page, all_count, url='myadmin/appointment', ) OneToOne.objects.filter() qs_obj = OneToOne.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] return render( request, 'myadmin/appointment.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'teacher_obj': teacher_obj, 'user_obj': user_obj })
def daily_pv(request): """ 每日pv统计 """ serch_value_list = ['daterange'] request_data = request.GET.get('get_data') if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: serch_dict[item] = GET[item] if serch_dict.get('daterange'): start, stop = serch_dict['daterange'].split(' - ') start = datetime.datetime.strptime(start, '%m/%d/%Y') stop = datetime.datetime.strptime(stop, '%m/%d/%Y') all_count = PVDaily.objects.filter(date__range=(start, stop)).count() else: all_count = PVDaily.objects.filter().count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/daily_pv', filter_args=filter_args) if serch_dict.get('daterange'): start, stop = serch_dict['daterange'].split(' - ') start = datetime.datetime.strptime(start, '%m/%d/%Y') stop = datetime.datetime.strptime(stop, '%m/%d/%Y') if start == stop: qs_obj = PVDaily.objects.filter(date=start).all() else: qs_obj = PVDaily.objects.filter(date__range=( start, stop)).all().order_by('date')[page_obj.start:page_obj.stop] else: qs_obj = PVDaily.objects.filter().all().order_by( 'date')[page_obj.start:page_obj.stop] if request_data == 'chart_data': data_list2 = [[], [], [], [], [], [], [], [], [], [], [], [], []] for i in qs_obj.values_list('date', 'area_id', 'POH', 'uv', 'userTotal', 'userIncr', 'pv'): count = 0 for j in range(len(i)): data_list2[count].append(i[count]) count += 1 return JsonResponse({ 'return_code': RETURN_CODE.SUCCESS, 'return_data': data_list2 }) return render(request, 'myadmin/daily_pv.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, })
def teacher(request): """ 教师管理 """ if request.method == "GET": serch_value_list = [ 'subject', 'grade', 'teacher_tag', 'enable', 'lt_grade', 'gte_grade' ] serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = TeacherInfo.objects.count() subject_obj = Subject.objects.all() grade_obj = CLASS_CHOICES teacher_label = TEACHER_LABEL page_obj = Pagefunc( current_page, all_count, url='myadmin/teacher', ) qs_obj = TeacherInfo.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] return render( request, 'myadmin/teacher_manage.html', { 'qs_obj': qs_obj, 'page_obj': page_obj.page(), 'grade_obj': grade_obj, 'subject_obj': subject_obj, 'teacher_label': teacher_label, })
def company(request): """ 公司管理页面 """ serch_value_list = ['name', 'enable'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = Company.objects.filter(**serch_dict).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/company', filter_args=filter_args) qs_obj = Company.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: if i == 'name': new_serch_dict[i] = serch_dict[i] else: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/company_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'serch_dict': new_serch_dict, })
def channel(request): """ 目录管理 """ serch_value_list = ['name', 'category_menu'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] category_menu_obj = CategoryMenu.objects.all() all_count = Channel.objects.count() type_choices = Channel.type_choices page_obj = Pagefunc(current_page, all_count, url='myadmin/channel') qs_obj = Channel.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] return render( request, 'myadmin/channel.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'category_menu_obj': category_menu_obj, 'type_choices': type_choices })
def message_push(request): """ 消息推送表 """ if request.method == "GET": current_page = request.GET.get('page', 1) all_count = MessagePush.objects.count() page_obj = Pagefunc(current_page, all_count, url='myadmin/system_push') qs_obj = MessagePush.objects.all()[page_obj.start:page_obj.stop] return render(request, 'myadmin/system_push.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj })
def categort_menu(request): """ 功能分类下的app(模块) """ serch_value_list = ['name', 'enable'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = CategoryMenu.objects.filter(**serch_dict).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/category_menu', filter_args=filter_args) grade_obj = CLASS_CHOICES version_choices = VERSION_CHOICES action_type = ACTION_TYPE().ACTION_CHOICE qs_obj = CategoryMenu.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: if i == 'name': new_serch_dict[i] = serch_dict[i] else: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/category_menu.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'grade_obj': grade_obj, 'version_choices': version_choices, 'action_type': action_type, 'serch_dict': new_serch_dict })
def tiku(request): """ 题库管理 """ serch_value_list = ['subject', 'grade', 'company', 'enable', 'name'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] company_obj = Company.objects.all() subject_obj = Subject.objects.all() grade_obj = CLASS_CHOICES all_count = Tiku.objects.filter(**serch_dict).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/tiku', filter_args=filter_args) qs_obj = Tiku.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: if i == 'name': new_serch_dict[i] = serch_dict[i] else: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/tiku_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'subject_obj': subject_obj, 'grade_obj': grade_obj, 'company_obj': company_obj, 'serch_dict': new_serch_dict })
def video(request): """ 视频 """ serch_value_list = ['category_menu', 'company', 'enable', 'title'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = Video.objects.filter(**serch_dict).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/video', filter_args=filter_args) category_menu_obj = CategoryMenu.objects.all() company_obj = Company.objects.all() album_obj = Album.objects.all() qs_obj = Video.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: if i == 'title': new_serch_dict[i] = serch_dict[i] else: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/video_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'category_menu_obj': category_menu_obj, 'company_obj': company_obj, 'album_obj': album_obj, 'serch_dict': new_serch_dict })
def category(request): """ 功能分类 """ serch_value_list = ['name'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = Category.objects.count() page_obj = Pagefunc(current_page, all_count, url='myadmin/category') qs_obj = Category.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] return render(request, 'myadmin/category.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj })
def index(request): """ 首页信息统计 """ request_data = request.GET.get('get_data') current_page = request.GET.get('page', 1) all_registered_count = User.objects.filter(enable=True).count() today = datetime.datetime.now() today_str = datetime.datetime.strftime(today, '%Y-%m-%d') today_datetime = datetime.datetime.strptime(today_str, '%Y-%m-%d') day_registered_count = User.objects.filter( created_time__gte=today_datetime).count() all_count = Company.objects.count() page_obj = Pagefunc(current_page, all_count, url='myadmin/index', data_num=20) company_obj = Company.objects.all()[page_obj.start:page_obj.stop] data_list = [] for c in company_obj: company_name = c.name video_count = c.video_set.count() tiku_count = c.tiku_set.count() textbook_count = c.textbook_set.count() all_count = video_count + tiku_count + textbook_count data_list.append( [company_name, video_count, tiku_count, textbook_count, all_count]) if request.method == "GET": if request_data == 'chart_data': return JsonResponse({ 'return_code': RETURN_CODE.SUCCESS, 'return_data': data_list }) return render( request, 'myadmin/index.html', { 'user_count': day_registered_count, 'data_list': data_list, 'page_obj': page_obj.page(), 'all_registered_count': all_registered_count, })
def textbook(request): """ 教材管理 """ serch_value_list = ['subject', 'grade', 'textbook_edition', 'enable'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] subject_obj = Subject.objects.all() grade_obj = CLASS_CHOICES textbook_edition_obj = TextbookEdition.objects.all() company_obj = Company.objects.all() all_count = Textbook.objects.filter(**serch_dict).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/textbook', filter_args=filter_args) qs_obj = Textbook.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/book_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'subject_obj': subject_obj, 'grade_obj': grade_obj, 'textbook_edition_obj': textbook_edition_obj, 'company_obj': company_obj, 'serch_dict': new_serch_dict, })
def admin_manage(request): """ 账号管理 """ from django.core.urlresolvers import resolve serch_value_list = ['username', 'is_active'] if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] permission_list = AdminUser._meta.permissions all_count = AdminUser.objects.filter(**serch_dict).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc( current_page, all_count, url='myadmin/admin_manage', filter_args=filter_args, ) qs_obj = AdminUser.objects.filter( **serch_dict).all()[page_obj.start:page_obj.stop] new_serch_dict = {} for i in serch_dict: if i == 'username': new_serch_dict[i] = serch_dict[i] else: new_serch_dict[i] = int(serch_dict[i]) return render( request, 'myadmin/admin_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'permission_list': permission_list, 'serch_dict': new_serch_dict })
def user(request): """ 用户 """ if request.method == "GET": serch_value_list = ['userid', 'province', 'city', 'school_name'] serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: if GET[item]: serch_dict[item] = GET[item] all_count = User.objects.count() page_obj = Pagefunc(current_page, all_count, url='myadmin/user') qs_obj = User.objects.filter( **serch_dict).values()[page_obj.start:page_obj.stop] return render(request, 'myadmin/user_manage.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, 'map_dict': MAP_DICT })
def logvisit(request): """ 访问者信息表 """ serch_value_list = ['daterange'] request_data = request.GET.get('get_data') if request.method == "GET": serch_dict = {} GET = request.GET current_page = GET.get('page', 1) for item in GET: if item in serch_value_list: serch_dict[item] = GET[item] if serch_dict.get('daterange'): start, stop = serch_dict['daterange'].split(' - ') start = datetime.datetime.strptime(start, '%m/%d/%Y') stop = datetime.datetime.strptime( stop, '%m/%d/%Y') + datetime.timedelta(days=1) all_count = LogVisit.objects.filter( first_visit_time__range=(start, stop)).count() else: start = datetime.date.today() stop = datetime.date.today() + datetime.timedelta( days=1) + datetime.timedelta(days=1) all_count = LogVisit.objects.filter( first_visit_time__range=(start, stop)).count() filter_args = '' for k, v in serch_dict.items(): filter_args += '&{0}={1}'.format(k, v) page_obj = Pagefunc(current_page, all_count, url='myadmin/logvisit', filter_args=filter_args) if serch_dict.get('daterange'): start, stop = serch_dict['daterange'].split(' - ') start = datetime.datetime.strptime(start, '%m/%d/%Y') stop = datetime.datetime.strptime(stop, '%m/%d/%Y') if start == stop: stop = start + datetime.timedelta(days=1) qs_obj = LogVisit.objects.filter( first_visit_time__range=(start, stop)).all().order_by( '-first_visit_time')[page_obj.start:page_obj.stop] else: stop = stop + datetime.timedelta(days=1) qs_obj = LogVisit.objects.filter( first_visit_time__range=(start, stop)).all().order_by( '-first_visit_time')[page_obj.start:page_obj.stop] else: start = datetime.date.today() stop = stop = datetime.date.today() + datetime.timedelta(days=1) qs_obj = LogVisit.objects.filter( first_visit_time__range=(start, stop)).all().order_by( '-first_visit_time')[page_obj.start:page_obj.stop] data_list2 = [] if request_data == 'chart_data': return JsonResponse({ 'return_code': RETURN_CODE.SUCCESS, 'return_data': data_list2 }) return render(request, 'myadmin/logvisit.html', { 'page_obj': page_obj.page(), 'qs_obj': qs_obj, })