Skip to content

Commit 45bebec

Browse files
committed
update apps
1 parent 518dc95 commit 45bebec

File tree

1,018 files changed

+198922
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,018 files changed

+198922
-76
lines changed

apps/cal/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# 選課小幫手(cal)
2+
3+
智慧行事曆,前身是選課小幫手。
4+
5+
1. [爬蟲](https://github.com/stufinite/campasscrawler)
6+
2. [搜尋引擎](https://github.com/Stufinite/curso)
7+
3. [課程代碼查詢api](https://github.com/Stufinite/cphelper)
8+
9+
## Getting Started
10+
11+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
12+
13+
### Prerequisities
14+
15+
1. OS:Ubuntu / OSX would be nice
16+
2. environment:need python3
17+
* Linux:`sudo apt-get update; sudo apt-get install; python3 python3-dev`
18+
* OSX:`brew install python3`
19+
3. 需要`mongoDB`:
20+
* Ubuntu:請看這篇[安裝教學](https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04)
21+
* mac:請看這篇[安裝教學](https://blog.gtwang.org/mac-os-x/mac-os-x-install-mongodb-database/)
22+
23+
### Installing
24+
25+
1. `git clone 本專案`
26+
2. 使用虛擬環境:
27+
1. 創建一個虛擬環境:`virtualenv venv`
28+
2. 啟動方法
29+
1. for Linux:`. venv/bin/activate`
30+
2. for Windows:`venv\Scripts\activate`
31+
3. `pip install -r requirements.txt`
32+
33+
## Running & Testing
34+
35+
## Run
36+
37+
1. 第一次的時候,需要先初始化資料庫:`python manage.py migrate`
38+
2. 把學校的系所資料匯入資料庫中:`python manage.py buildDept NCHU`
39+
3. 切換到 [scrawler](http://github.com/stufinite/scrawler) ,執行 `scrapy crawl NCHU` (詳細操作請看scrawler的README)
40+
4. Execute:`python manage.py runserver`. If it work fine on [here](127.0.0.1:8000) , then it's done. Congratulations~~
41+
42+
### Break down into end to end tests
43+
44+
目前還沒寫測試...
45+
46+
### And coding style tests
47+
48+
目前沒有coding style tests...
49+
50+
### Results
51+
52+
輸入相對應的url pattern就會到相對應的頁面:
53+
1. `127.0.0.1:8000`:就會到選課小幫手的頁面
54+
2. `127.0.0.1:8000/tiagenda`:就會到tiagenda的頁面
55+
56+
## Deployment
57+
58+
There is no difference between other Django project
59+
60+
You can deploy it with uwsgi, gunicorn or other choice as you want
61+
62+
`選課小幫手` 是一般的django專案,所以他佈署的方式並沒有不同
63+
64+
## Built With
65+
66+
* python3.5
67+
* Django==1.10.4
68+
69+
## Versioning
70+
71+
For the versions available, see the [tags on this repository](https://github.com/david30907d/KCM/releases).
72+
73+
## Contributors
74+
75+
* **張泰瑋** [david](https://github.com/david30907d)
76+
* **黃川哲**
77+
* **柯秉廷**
78+
79+
## License
80+
81+
## Acknowledgments

apps/cal/cal/cal/__init__.py

Whitespace-only changes.

apps/cal/cal/cal/settings.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
"""
2+
Django settings for cal project.
3+
4+
Generated by 'django-admin startproject' using Django 1.10.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.10/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/1.10/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
# Domain name
19+
DOMAIN = 'campass.com.tw'
20+
USERPOOL_URL = 'http://login.campass.com.tw'
21+
22+
# Quick-start development settings - unsuitable for production
23+
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
24+
25+
# SECURITY WARNING: keep the secret key used in production secret!
26+
with open(BASE_DIR + '/config/' + 'secret_key.txt') as f:
27+
SECRET_KEY = f.read().strip()
28+
29+
# SECURITY WARNING: don't run with debug turned on in production!
30+
DEBUG = False
31+
# DEBUG = True
32+
33+
ALLOWED_HOSTS = ['.' + DOMAIN, 'localhost', '127.0.0.1', '0.0.0.0']
34+
35+
36+
# Application definition
37+
38+
REQUIRED_APPS = [
39+
'django.contrib.admin',
40+
'django.contrib.auth',
41+
'django.contrib.contenttypes',
42+
'django.contrib.sessions',
43+
'django.contrib.messages',
44+
'django.contrib.staticfiles',
45+
]
46+
47+
PROJECT_APPS = [
48+
'timetable.apps.TimetableConfig',
49+
'tiagenda',
50+
'cphelper',
51+
'curso',
52+
]
53+
54+
INSTALLED_APPS = REQUIRED_APPS + PROJECT_APPS
55+
56+
MIDDLEWARE = [
57+
'django.middleware.security.SecurityMiddleware',
58+
'django.contrib.sessions.middleware.SessionMiddleware',
59+
'django.middleware.common.CommonMiddleware',
60+
'django.middleware.csrf.CsrfViewMiddleware',
61+
'django.contrib.auth.middleware.AuthenticationMiddleware',
62+
'django.contrib.messages.middleware.MessageMiddleware',
63+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
64+
]
65+
66+
ROOT_URLCONF = 'cal.urls'
67+
68+
TEMPLATES = [
69+
{
70+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
71+
'DIRS': ['templates'],
72+
'APP_DIRS': True,
73+
'OPTIONS': {
74+
'context_processors': [
75+
'django.template.context_processors.debug',
76+
'django.template.context_processors.request',
77+
'django.contrib.auth.context_processors.auth',
78+
'django.contrib.messages.context_processors.messages',
79+
],
80+
},
81+
},
82+
]
83+
84+
WSGI_APPLICATION = 'cal.wsgi.application'
85+
86+
87+
# Password validation
88+
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
89+
90+
AUTH_PASSWORD_VALIDATORS = [
91+
{
92+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
93+
},
94+
{
95+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
96+
},
97+
{
98+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
99+
},
100+
{
101+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
102+
},
103+
]
104+
105+
106+
# Internationalization
107+
# https://docs.djangoproject.com/en/1.10/topics/i18n/
108+
109+
LANGUAGE_CODE = 'en-us'
110+
111+
TIME_ZONE = 'Asia/Taipei'
112+
113+
USE_I18N = True
114+
115+
USE_L10N = True
116+
117+
USE_TZ = True
118+
119+
120+
# Settings for our specific uses
121+
122+
# Database
123+
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
124+
125+
from .settings_database import DATABASE_SETTINGS
126+
if DEBUG:
127+
DATABASES = DATABASE_SETTINGS['sqlite']
128+
else:
129+
DATABASES = DATABASE_SETTINGS['sqlite']
130+
131+
# Static files (CSS, JavaScript, Images)
132+
# https://docs.djangoproject.com/en/1.10/howto/static-files/
133+
134+
STATIC_URL = '/static/'
135+
STATIC_ROOT = ''
136+
STATICFILES_DIRS = [
137+
os.path.join(BASE_DIR, "static"),
138+
]
139+
140+
# Shared session
141+
142+
SESSION_COOKIE_DOMAIN = '.' + DOMAIN
143+
with open(BASE_DIR + '/config/' + 'sessionid.txt') as f:
144+
SESSION_COOKIE_NAME = f.read().strip()
145+
146+
# Dev
147+
148+
if DEBUG:
149+
USERPOOL_URL = 'http://test.localhost.login.campass.com.tw'
150+
del SESSION_COOKIE_DOMAIN
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
3+
from .settings import BASE_DIR
4+
5+
DATABASE_SETTINGS = {
6+
'sqlite': {
7+
'default': {
8+
'ENGINE': 'django.db.backends.sqlite3',
9+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
10+
}
11+
},
12+
'mysql': {
13+
'default': {
14+
'ENGINE': 'django.db.backends.mysql',
15+
'NAME': 'cal',
16+
'USER': 'mydatabaseuser',
17+
'PASSWORD': 'mypassword',
18+
'HOST': '127.0.0.1',
19+
'PORT': '5432',
20+
}
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
3+
from .settings import BASE_DIR
4+
5+
DATABASE_SETTINGS = {
6+
'sqlite': {
7+
'default': {
8+
'ENGINE': 'django.db.backends.sqlite3',
9+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
10+
}
11+
},
12+
'mysql': {
13+
'default': {
14+
'ENGINE': 'django.db.backends.mysql',
15+
'NAME': 'cal',
16+
'USER': 'root',
17+
'PASSWORD': 'suckmydick87',
18+
'HOST': '127.0.0.1',
19+
'PORT': '3306',
20+
}
21+
}
22+
}

apps/cal/cal/cal/urls.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""cal URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/1.10/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.conf.urls import url, include
14+
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
15+
"""
16+
from django.conf.urls import url, include
17+
from django.contrib import admin
18+
19+
urlpatterns = [
20+
url(r'^admin/', admin.site.urls),
21+
url(r'^', include('timetable.urls')),
22+
url(r'^tiagenda/', include('tiagenda.urls')),
23+
]
24+
25+
# 課搜(curso)
26+
# https://github.com/Stufinite/curso
27+
28+
import curso.urls
29+
urlpatterns += [
30+
url(r'^search/', include(curso.urls))
31+
]
32+
33+
34+
# 課程資料查詢API
35+
# https://github.com/Stufinite/cphelper
36+
37+
import cphelper.urls
38+
urlpatterns += [
39+
url(r'^course/', include(cphelper.urls))
40+
]

apps/cal/cal/cal/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for cal project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cal.settings")
15+
16+
application = get_wsgi_application()

apps/cal/cal/config/secret_key.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PutYourSecretKeyHere

apps/cal/cal/config/sessionid.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PutYourSessionIdHere

apps/cal/cal/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cal.settings")
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError:
10+
# The above import may fail for some other reason. Ensure that the
11+
# issue is really that Django is missing to avoid masking other
12+
# exceptions on Python 2.
13+
try:
14+
import django
15+
except ImportError:
16+
raise ImportError(
17+
"Couldn't import Django. Are you sure it's installed and "
18+
"available on your PYTHONPATH environment variable? Did you "
19+
"forget to activate a virtual environment?"
20+
)
21+
raise
22+
execute_from_command_line(sys.argv)

0 commit comments

Comments
 (0)