Skip to content

Commit

Permalink
项目结构调整
Browse files Browse the repository at this point in the history
  • Loading branch information
stormsha committed Apr 10, 2019
1 parent cd6dc30 commit 10983b7
Show file tree
Hide file tree
Showing 2,051 changed files with 144,240 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
@@ -1,2 +1,50 @@
# StormOnline
使用Python2.7.x与Django1.9开发的在线教育平台网站(跟着慕课booby老师的课程学习开发)

# stormsha

[![Build Status](https://travis-ci.org/stormsha/hexoBlog-Github.svg?branch=master)](https://travis-ci.org/stormsha/hexoBlog-Github)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)

使用Python2.7.x与Django1.9开发的在线教育平台网站: [http://stormsha1.pythonanywhere.com/](http://stormsha1.pythonanywhere.com/)

目前注册出现问题还未修复

## Quick Start
$ git clone https://github.com/stormsha/StormOnline.git
$ cd StormOnline
$ pip install -r requirements.txt
$ python manage.py runserver


use the address: http://127.0.0.1:8000/

## Contents:


**欢迎大家关注订阅,点赞!!!**

## Background:

- 最近重装了系统,所以从环境配置开始,我都做到尽可能从零开始,对初学者友好。
- 自己已经学习Python一年了,但是是一些陈旧的知识已经淡忘,最近对于Python相关开始进行一个基本的复习。
- 希望可以帮到那些对于Python,对Django有兴趣的同学少走弯路。

[项目线上演示地址](http://stormsha1.pythonanywhere.com/)

[原版视频课程地址:](https://coding.imooc.com/learn/list/78.html)

>一次性的一个完整项目代码很难被学习
- 每节教程前面会写明对应的上节commit:开始某一节教程的前置条件。
- 每节教程后面会写明对应的已结束commit: 方便本节出错参考。

希望可以对Django初学者,Python爱好者有所帮助。

## About me
[CSDN](https://blog.csdn.net/sxc1414749109)

[个人站点](https://stormsha.com/)



2 changes: 2 additions & 0 deletions StormOnline/__init__.py
@@ -0,0 +1,2 @@


232 changes: 232 additions & 0 deletions StormOnline/settings.py
@@ -0,0 +1,232 @@
# -*-coding:utf-8-*-
"""
Django settings for StormOnline project.
Generated by 'django-admin startproject' using Django 1.9.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
# import django
# django.setup()
import os
import sys

# Build paths inside the project like this: os.path.join(BASE_DIR, /static.)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# -------------register-apps---------------------------------------
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
sys.path.insert(1, os.path.join(BASE_DIR, "extra_apps"))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'j1g!kza1uq5cwa52*b1oq0v*vt2xz2&h*5o9r!)uj6+80va#(n'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['stormsha1.pythonanywhere.com']


# Application definition
AUTHENTICATION_BACKENDS = [
'users.views.CustomBackend',
]

# -----------------apps-----------------------
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users',
'courses',
'organization',
'operation',
'xadmin',
'crispy_forms',
'reversion',
'captcha',
'pure_pagination',
'ueditor',
'ckeditor',
'ckeditor_uploader',
'DjangoUeditor'
]
# -------------------继承model------------------------
AUTH_USER_MODEL = "users.UserProfile"


MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'StormOnline.urls'

# ----------------------html------------------------------------------
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.media',
],
},
},
]

WSGI_APPLICATION = 'StormOnline.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases


# -----------------------sql---------------------------------------
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'stormsha1$stormsha',
'USER': 'stormsha1',
'PASSWORD': 'stormsha@sina.com',
'HOST': 'stormsha1.mysql.pythonanywhere-services.com'
}
}


# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

# ----------------网站语言--------------------------------------
LANGUAGE_CODE = 'zh-hans'

# ----------------时区------------------------------------------
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
# 国际时间
# USE_TZ = True
# 本地时间
USE_TZ = False
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

# -------------------静态文件-----------------------------
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]


# ------------第三方收发邮件---------------
EMAIL_HOST = "smtp.sina.com"
EMAIL_PORT = 25
EMAIL_HOST_USER = "stormsha@sina.com"
EMAIL_HOST_PASSWORD = "sxc123654"
EMAIL_USE_TLS = False
EMAIL_FROM = "stormsha@sina.com"


# -----------------上传图片-----------------------------
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')





# 配置ckeditor
CKEDITOR_UPLOAD_PATH = 'upload/'
CKEDITOR_IMAGE_BACKEND = 'pillow'
# CKEDITOR_CONFIGS = {
# 'comment_ckeditor': {
# 'toolbar': 'custom',
# 'toolbar_custom': [
# ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'],
# ["TextColor", "BGColor", 'RemoveFormat'],
# ['NumberedList', 'BulletedList'],
# ['Link', 'Unlink'],
# ["Smiley", "SpecialChar", 'Blockquote'],
# ],
# 'width': 'auto',
# 'height': '180',
# 'tabSpaces': 4,
# 'removePlugins': 'elementspath',
# 'resize_enabled': False,
# }
# }

CKEDITOR_CONFIGS = {
'default': {},
'comment_ckeditor': {
'toolbar': (
['div','Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button', 'ImageButton','HiddenField'],
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize','ShowBlocks','-','About', 'pbckcode'],
),
},
'你的Ckeditor工具栏名':{
'toolbar':(
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
['Styles','Format','Font','FontSize'],
),
'filebrowserWindowWidth': 940,
'filebrowserWindowHeight': 725,
'width': 'auto',
'height': 180,
'tabSpaces': 4,
'removePlugins': 'elementspath',
'resize_enabled': False,
}
}
63 changes: 63 additions & 0 deletions StormOnline/urls.py
@@ -0,0 +1,63 @@
# _ * _ coding: utf-8 _ * _
"""StormOnline URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Import the include() function: from django.conf.urls import url, include
3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
# ---------------python-------------------------
import xadmin
# ---------------django-------------------------
from django.conf.urls import url, include
from django.views.generic import TemplateView
from django.views.static import serve
from StormOnline.settings import MEDIA_ROOT
# ---------------model--------------------------
from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView, LogoutView
from users.views import IndexView
from organization.views import OrgView

# ----------------url------------------------------
urlpatterns = [
url(r'^xadmin/', xadmin.site.urls),
url(r'^$', IndexView.as_view(), name="index"),

# -------------------------user--------------------------
url(r'^login/$', LoginView.as_view(), name="login"),
url(r'^logout/$', LogoutView.as_view(), name="logout"),
url(r'^register/$', RegisterView.as_view(), name="register"),
url(r'^captcha/', include('captcha.urls')),
url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name="user_active"),
url(r'^forget/$', ForgetPwdView.as_view(), name="forget_pwd"),
url(r'^reset/(?P<reset_code>.*)/$', ResetView.as_view(), name="reset_pwd"),
url(r'^modify/$', ModifyPwdView.as_view(), name="modify_pwd"),

# -----------------------organization----------------------
url(r'^org/', include('organization.urls', namespace="org", app_name='organization')),
# -----------------------course-----------------------------
url(r'^course/', include('courses.urls', namespace="course")),
# -----------------------配置上传文件的访问处理函数路径---------------------
url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}),
#url(r'^static/(?P<path>.*)$', serve, {"document_root": STATIC_ROOT}),
# -------------------------user_center---------------------------------
url(r'^users/', include('users.urls', namespace="users")),
# ----------------富文本编辑器-------------------------------------
url(r'^ueditor/', include('DjangoUeditor.urls')),
url(r'^ckeditor/', include('ckeditor_uploader.urls'))

]

# 全局404页面配置
handler404 = 'users.views.page_not_found'
# 全局500页面配置
handler500 = 'users.views.page_error'
16 changes: 16 additions & 0 deletions StormOnline/wsgi.py
@@ -0,0 +1,16 @@
"""
WSGI config for StormOnline project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "StormOnline.settings")

application = get_wsgi_application()
Empty file added apps/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions apps/courses/__init__.py
@@ -0,0 +1,2 @@
default_app_config = "courses.apps.CoursesConfig"

3 changes: 3 additions & 0 deletions apps/courses/admin.py
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.

0 comments on commit 10983b7

Please sign in to comment.