from __future__ import absolute_import
from collections import OrderedDict
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
from django.core.paginator import InvalidPage, Paginator
from django.core.urlresolvers import NoReverseMatch
from django.db import models
from django.http import HttpResponseRedirect
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils import six
from django.utils.encoding import force_text, smart_text
from django.utils.html import escape, conditional_escape
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
from xadmin.util import lookup_field, display_for_field, label_for_field, boolean_icon
from .base import ModelAdminView, filter_hook, inclusion_tag, csrf_protect_m
# List settings
ALL_VAR = 'all'
ORDER_VAR = 'o'
PAGE_VAR = 'p'
TO_FIELD_VAR = 't'
COL_LIST_VAR = '_cols'
ERROR_FLAG = 'e'
DOT = '.'
# Text to display within change-list table cells if the value is blank.
EMPTY_CHANGELIST_VALUE = _('Null')
class FakeMethodField(object):
"""
This class used when a column is an model function, wrap function as a fake field to display in select columns.
"""
def __init__(self, name, verbose_name):
# Initial comm field attrs
self.name = name
self.verbose_name = verbose_name
self.primary_key = False
class ResultRow(dict):
pass
class ResultItem(object):
def __init__(self, field_name, row):
self.classes = []
self.text = ' '
self.wraps = []
self.tag = 'td'
self.tag_attrs = []
self.allow_tags = False
self.btns = []
self.menus = []
self.is_display_link = False
self.row = row
self.field_name = field_name
self.field = None
self.attr = None
self.value = None
@property
def label(self):
text = mark_safe(
self.text) if self.allow_tags else conditional_escape(self.text)
if force_text(text) == '':
text = mark_safe(' ')
for wrap in self.wraps:
text = mark_safe(wrap % text)
return text
@property
def tagattrs(self):
return mark_safe(
'%s%s' % ((self.tag_attrs and ' '.join(self.tag_attrs) or ''),
(self.classes and (' class="%s"' % ' '.join(self.classes)) or '')))
class ResultHeader(ResultItem):
def __init__(self, field_name, row):
super(ResultHeader, self).__init__(field_name, row)
self.tag = 'th'
self.tag_attrs = ['scope="col"']
self.sortable = False
self.allow_tags = True
self.sorted = False
self.ascending = None
self.sort_priority = None
self.url_primary = None
self.url_remove = None
self.url_toggle = None
class ListAdminView(ModelAdminView):
"""
Display models objects view. this class has ordering and simple filter features.
"""
list_display = ('__str__',)
list_display_links = ()
list_display_links_details = False
list_select_related = None
list_per_page = 50
list_max_show_all = 200
list_exclude = ()
search_fields = ()
paginator_class = Paginator
ordering = None
# Change list templates
object_list_template = None
def init_request(self, *args, **kwargs):
if not self.has_view_permission():
raise PermissionDenied
request = self.request
request.session['LIST_QUERY'] = (self.model_info, self.request.META['QUERY_STRING'])
self.pk_attname = self.opts.pk.attname
self.lookup_opts = self.opts
self.list_display = self.get_list_display()
self.list_display_links = self.get_list_display_links()
# Get page number parameters from the query string.
try:
self.page_num = int(request.GET.get(PAGE_VAR, 0))
except ValueError:
self.page_num = 0
# Get params from request
self.show_all = ALL_VAR in request.GET
self.to_field = request.GET.get(TO_FIELD_VAR)
self.params = dict(request.GET.items())
if PAGE_VAR in self.params:
del self.params[PAGE_VAR]
if ERROR_FLAG in self.params:
del self.params[ERROR_FLAG]
@filter_hook
def get_list_display(self):
"""
Return a sequence containing the fields to be displayed on the list.
"""
self.base_list_display = (COL_LIST_VAR in self.request.GET and self.request.GET[COL_LIST_VAR] != "" and \
self.request.GET[COL_LIST_VAR].split('.')) or self.list_display
return list(self.base_list_display)
@filter_hook
def get_list_display_links(self):
"""
Return a sequence containing the fields to be displayed as links
on the changelist. The list_display parameter is the list of fields
returned by get_list_display().
"""
if self.list_display_links or not self.list_display:
return self.list_display_links
else:
# Use only the first item in list_display as link
return list(self.list_display)[:1]
def make_result_list(self):
# Get search parameters from the query string.
self.base_queryset = self.queryset()
self.list_queryset = self.get_list_queryset()
self.ordering_field_columns = self.get_ordering_field_columns()
self.paginator = self.get_paginator()
# Get the number of objects, with admin filters applied.
self.result_count = self.paginator.count
# Get the total number of objects, with no admin filters applied.
# Perform a slight optimization: Check to see whether any filters were
# given. If not, use paginator.hits to calculate the number of objects,
# because we've already done paginator.hits and the value is cached.
if not self.list_queryset.query.where:
self.full_result_count = self.result_count
else:
self.full_result_count = self.base_queryset.count()
self.can_show_all = self.result_count <= self.list_max_show_all
self.multi_page = self.result_count > self.list_per_page
# Get the list of objects to display on this page.
if (self.show_all and self.can_show_all) or not self.multi_page:
self.result_list = self.list_queryset._clone()
else:
try:
self.result_list = self.paginator.page(
self.page_num + 1).object_list
except InvalidPage:
if ERROR_FLAG in self.request.GET.keys():
return SimpleTemplateResponse('xadmin/views/invalid_setup.html', {
'title': _('Database error'),
})
return HttpResponseRedirect(self.request.path + '?' + ERROR_FLAG + '=1')
self.has_more = self.result_count > (
self.list_per_page * self.page_num + len(self.result_list))
@filter_hook
def get_result_list(self):
return self.make_result_list()
@filter_hook
def post_result_list(self):
return self.make_result_list()
@filter_hook
def get_list_queryset(self):
"""
Get model queryset. The query has been filted and ordered.
"""
# First, get queryset from base class.
queryset = self.queryset()
# Use select_related() if one of the list_display options is a field
# with a relationship and the provided queryset doesn't already have
# select_related defined.
if not queryset.query.select_related:
if self.list_select_related:
queryset = queryset.select_related()
elif self.list_select_related is None:
related_fields = []
for field_name in self.list_display:
try:
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一个基于Python和Django的在线课程教育平台,包含767个文件,主要文件类型包括图片、JavaScript脚本、Python源代码、HTML页面、CSS样式表、JavaScript对象文件、Python对象文件、图片、GIF动画和字体文件。系统设计旨在为用户提供一个高仿慕课网的在线课程学习平台,支持用户注册、登录、浏览课程、学习课程内容等功能。
资源推荐
资源详情
资源评论
收起资源包目录
基于Python和Django的在线课程教育平台设计源码 (776个子文件)
my.cnf 247B
mx_nginx.conf 690B
config 335B
style.css 156KB
bootstrap.css 123KB
bootstrap.min.css 100KB
animate.css 72KB
aui.css 61KB
common-less.css 48KB
video-js.min.css 39KB
mobiscroll.css 26KB
common-less.css 22KB
font-awesome.css 21KB
mooc.css 20KB
bootstrap-theme.css 19KB
select2.css 19KB
font-awesome.min.css 17KB
bootstrap-theme.min.css 17KB
course-comment.css 16KB
selectize.bootstrap2.css 15KB
selectize.default.css 11KB
layer.css 11KB
selectize.legacy.css 11KB
selectize.bootstrap3.css 10KB
cityLayout.css 10KB
datepicker.css 10KB
learn-less.css 9KB
login.css 9KB
selectize.css 8KB
xadmin.main.css 8KB
laydate.css 6KB
lq.datetimepick.css 5KB
base.css 4KB
xadmin.responsive.css 4KB
bootstrap-modal.css 4KB
xadmin.form.css 4KB
bootstrap-clockpicker.css 4KB
laydate.css 3KB
bootstrap-image-gallery.css 3KB
bootstrap-clockpicker.min.css 3KB
layer.ext.css 3KB
reset.css 3KB
bootstrap-timepicker.css 3KB
bootstrap-image-gallery.min.css 2KB
bootstrap-timepicker.min.css 2KB
xadmin.widget.select-transfer.css 2KB
bootstrap-xadmin.css 2KB
xadmin.mobile.css 1KB
snap.css 1KB
xadmin.plugin.formset.css 1KB
xadmin.widget.editable.css 1KB
xadmin.page.dashboard.css 790B
xadmin.plugin.quickfilter.css 248B
xadmin.plugins.css 175B
xadmin.plugin.aggregation.css 95B
bootstrap-multiselect.css 0B
Dockerfile 425B
fontawesome-webfont.eot 37KB
glyphicons-halflings-regular.eot 20KB
background.gif 8KB
loading-0.gif 6KB
loading.gif 4KB
help_index_pic.gif 2KB
rolling.gif 2KB
select2-spinner.gif 2KB
loading-2.gif 2KB
ajax-loader.gif 2KB
select-arr-default.gif 1KB
pop-tips-info-arr.gif 1KB
loading-1.gif 701B
pixel.gif 43B
.gitignore 75B
.gitkeep 0B
usercenter-base.html 9KB
course-comment.html 8KB
org-base.html 8KB
org-list.html 7KB
teacher-detail.html 7KB
course-video.html 7KB
course-play.html 7KB
course-detail.html 6KB
base.html 6KB
model_list.html 5KB
index.html 5KB
teachers-list.html 4KB
course-list.html 4KB
usercenter-info.html 4KB
base_site.html 4KB
register.html 4KB
forgetpwd.html 3KB
date.html 3KB
login.html 3KB
login.html 3KB
model_list.top_toolbar.exports.html 3KB
number.html 3KB
usercenter-message.html 2KB
usercenter-fav-teacher.html 2KB
org-detail-homepage.html 2KB
model_delete_selected_confirm.html 2KB
model_history.html 2KB
共 776 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
沐知全栈开发
- 粉丝: 5816
- 资源: 5227
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- c#winform贪吃蛇
- 激光熔覆数值模拟 COMSOL仿真 双椭球热源 采用双椭球热源模型,考虑材料热物性参数、相变、马兰戈尼效应、布辛涅斯克近似等,动网格模拟熔覆层,计算瞬态温度场和流场
- mmexport1735817657310.png
- mmexport1735817655874.png
- 编程直接实现HTML网页跨年倒计时计数的代码
- 基于SpringBoot+Vue.JS开发的校园闲置物品交易系统 JAVA毕业设计 源码+数据库+论文(有项目截图)+启动教程
- 使用Java实现的简单药品库存管理系统
- 校园闲置物品交易网站 毕业设计 源码+数据库+论文(JAVA+SpringBoot+Vue.JS).zip
- IEEE39节点暂态模型,包括simulink与PSCAD两类仿真模型 (运行时先运行m文件) IEEE39节点标准系统,标准算例数据,电源采用发电机模型,更能考虑完备暂态响应 适合新手学习所用
- 服装加工厂管理系统 本系统有完整的系统,包括代码和数据库
- 配网潮流计算 MATLAB编程 1.配网潮流计算(前推回代法) 2.考虑分布式电源对配网潮流的影响 注:下图为IEEE33节点系统接入分布式电源之后的潮流仿真图
- 26页-基于AI人工智能的智慧校园综合解决方案AI+智慧校园综合解决方案.pdf
- 28页-医信签OA办公移动电子签名平台解决方案.pdf
- 37页-AI云名片解决方案(智能销售新时代).pdf
- 12903springboot校园二手平台 源码.zip
- AI大模型对智能汽车产业的影响(2023-9)PPT(26页).pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功