Skip to content

ccwen/devtusita

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Source Code for Personal Page of Tusita Hermitage

The website is powered by Google App Engine, AngularJS, Bootstrap, and Glyphicons Halflings.

系統設計

登入前: 僅看得到Welcome及News.

登入後(僅限Google帳號登入): 瀏覽器從伺服器讀取該帳號基本資料(註1),若:

    1. 讀不到的到基本資料(第一次登入):強制導到填寫基本資料畫面,若不填寫則無法進入其他畫面,填寫後瀏覽器會把基本資料存到伺服器(註2)
    1. 讀得到的到基本資料:系統管理者會看到六個頁面,登入使用者則會看到四個頁面:
    • (一)更新我的資料(登入使用者皆可看到): 在此可修改基本資料,修改後瀏覽器會把修改的資料存到伺服器.(註3)
    • (二)禪修申請(登入使用者皆可看到): 點選此頁面,瀏覽器會從伺服器讀取目前所有的禪修期,顯示在申請表上給使用者選擇,等使用者填好後,把使用者申請資料存到伺服器(註4)
    • (三)禪修申請記錄(登入使用者皆可看到): 顯示使用者所有的禪修申請紀錄(註5)
    • (四)新增禪修期(僅系統管理者可看到): 系統管理員可新增禪修期讓使用者在禪修申請頁面選擇.(註6)
    • (五)管理禪修期(僅系統管理者可看到): 瀏覽器會從伺服器讀取所有的禪修期並顯示出來,系統管理員可選擇其中一個禪修期並修改之,修改後會把此修改存回伺服器.(註7)
    • (六)首頁(登入使用者皆可看到): 顯示Welcome及News.

為了簡化開發及維護,禪師必須加為系統管理者才可新增及管理禪修期.

附註:

註1:透過RESTful api(網址: /RESTful/{{email}}, 舉例來說,若使用者登入時的email是example@gmail.com, 則為/RESTful/example@gmail.com)讀取基本資料(讀取Person model)

註2:資料打包成json透過RESTful api ( 網址: /RESTful/{{email}} ) 傳到server存起來.(存到Person model)

註3:資料打包成json透過RESTful api ( 網址: /RESTful/{{email}} ) 傳到server存起來.(存到Person model)

註4:瀏覽器會先透過RESTful api( 網址: /RESTful/{{email}}/retreat )讀取所有的禪修期(讀取Retreat model),並顯示在申請表單上給申請者選擇,申請者填寫送出後將資料打包成json透過RESTful api( 網址: /RESTful/{{email}}/apply )傳到server存起來(存到MedAppForm model), server會同時更新Person model,將此MedAppForm model entity的key附加在該使用者Person model entity的activeMedAppForm欄位,這樣做是為了之後server可以讀取該使用者的所有禪修申請.

註5:透過RESTful api( 網址: /RESTful/{{email}}/apply )讀取該使用者的所有申請資料.(先讀取Person model的activeMedAppForm欄位裡的key(s),再從key(s)讀取MedAppForm model)

註6:填寫送出後,資料打包成json透過RESTful api( 網址: /RESTful/{{email}}/retreat )傳到server存起來.(存到Retreat model)

註7:透過RESTful api( 網址: /RESTful/{{email}}/retreat )讀取所有禪修期資料(讀取Retreat model),系統管理者修改其中一個禪修期後,再透過同一個api存起來.

Setup of Development Environment

REPO_DIR below means the directory where you git clone this repository. GAE_PYSDK_DIR means the directory of Google App Engine Python SDK.

  • Create i18n files for production use:
    cd REPO_DIR/pytools/
    # create i18n files
    python i18nUtils.py pot
    python i18nUtils.py po

    # create JavaScript file ( REPO_DIR/app/js/locales.js ) of translated strings for client side
    python i18nUtils.py js

FIXME: how to use msg tools on Windows system?

Development

  • app.yaml, main.py, database.py : files on Google App Engine server(s). Written in Python programming language. These files route and handles user http requests.
  • app/* : files on client side, i.e., run on user browser. Use AngularJS to simplify development process.
    1. app/index.html : home page of the website. (The first page served when users visits the website)
    2. app/css/* : css file(s) goes here.
    3. app/js/* : JavaScript files goes here. (use AngularJS)
    4. app/img/* : image files goes here.
    5. app/partials/* : partial html files used by AngularJS.

Database

Several models are used to store data on server. The first is:

Person

class Person(ndb.Model):
  json = ndb.TextProperty()
  activeMedAppForm = ndb.KeyProperty(repeated = True)

This is a model inherited from ndb.Model to store basic information of users, such as name, birthday, and etc. There are two properties in this Person model, json and activeMedAppForm. The field json stores user information in JSON format, and the field activeMedAppForm stores key(s) of user meditation application(s). The data of user meditation application is stored in another model called MedAppForm, which will be described next.

MedAppForm

class MedAppForm(ndb.Model):
  json = ndb.TextProperty()
  retreat = ndb.KeyProperty()

This model stores the user meditation application. The field json stores the form data in JSON format, and the field retreat stores the retreat that meditators apply for.

Retreat

class Retreat(ndb.Model):
  json = ndb.TextProperty()
  startDate = ndb.DateProperty()

This model stores the retreat data that created by system adminstrators. The field json stores the retreat data (such as start_date and end_date) in json format, and the field startDate stores the beginning date of the retreat in Python date format.

RESTful API

The are repective API for each model:

RESTful API for Person

CRUD (create, read, update, and delete) are all supported. The url for communication is /RESTful/{{email}}, where {{email}} is the email address of the user.

RESTful API for MedAppForm

Only create and read are supported. The url is /RESTful/{{email}}/apply, where {{email}} is the email address of the user. The read operation will return all applied form(s) back to client.

RESTful API for Retreat

create, read, update are supported. The url is /RESTful/{{email}}/retreat, where {{email}} is the email address of the user. The read operation will return all retreats back to client.

About

source code for devtusita.appspot.com

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 82.3%
  • HTML 12.3%
  • Python 3.9%
  • CSS 1.5%