Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sync#39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
TommyLemon merged 3 commits intoAPIJSON:masterfromzhangchunlin:master
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletionstests/demo/.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
*.pyc
*.bak
local_settings.ini
build
dist
*.egg-info
.idea
_git
data
database.db
sessions
4 changes: 4 additions & 0 deletionstests/demo/apps/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
__version__ = '0.1'
__url__ = ''
__author__ = ''
__email__ = ''
View file
Open in desktop
Empty file.
View file
Open in desktop
Empty file.
158 changes: 158 additions & 0 deletionstests/demo/apps/apijson_demo/dbinit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
#coding=utf-8
from uliweb import models
from uliweb.orm import set_dispatch_send

set_dispatch_send(False)

User = models.user
Privacy = models.privacy
Comment = models.comment
Moment = models.moment
PublicNotice = models.publicnotice

user_list = [
{
"username": "admin",
"nickname": "Administrator",
"email": "admin@localhost",
"date_join": "2018-1-1",
},
{
"username": "usera",
"nickname": "User A",
"email": "usera@localhost",
"date_join": "2018-2-2",
},
{
"username": "userb",
"nickname": "User B",
"email": "userb@localhost",
"date_join": "2018-3-3",
},
{
"username": "userc",
"nickname": "User C",
"email": "userc@localhost",
"date_join": "2018-4-4",
},
]

privacy_list = [
{
"username" : "usera",
"certified" : True,
"phone" : "13333333333",
"balance" : 100,
"password" : "hash_of_123",
"paypassword" : "hash_of_sudfy8e7r",
},
{
"username" : "userb",
"certified" : True,
"phone" : "12222222222",
"balance" : 130,
"password" : "hash_of_dfdfd",
"paypassword" : "hash_of_234erere",
},
{
"username" : "userc",
"certified" : True,
"phone" : "14323424234",
"balance" : 600,
"password" : "hash_of_w3erere",
"paypassword" : "hash_of_ghtwertr",
},
]

moment_list = [
{
"username" : "usera",
"date" : "2018-11-1",
"content" : "test moment",
},
{
"username" : "userb",
"date" : "2018-11-2",
"content" : "test moment from b",
},
{
"username" : "userc",
"date" : "2018-11-6",
"content" : "test moment from c",
},
]

comment_list = [
{
"username" : "usera",
"to_username" : "userb",
"moment_id" : 1,
"date" : "2018-12-1",
"content" : "comment haha",
},
{
"username" : "userb",
"to_username" : "usera",
"moment_id" : 2,
"date" : "2018-12-2",
"content" : "comment xixi",
},
{
"username" : "userc",
"to_username" : "usera",
"moment_id" : 3,
"date" : "2018-12-9",
"content" : "comment hoho",
},
]

publicnotice_list = [
{
"date" : "2018-12-9",
"content" : "notice: a",
},
{
"date" : "2018-12-18",
"content" : "notice: b",
},
]

for d in user_list:
if not User.get(User.c.username==d["username"]):
print("create user '%s'"%(d["username"]))
u = User(**d)
u.set_password("123")
if d["username"]=="admin":
u.is_superuser = True
u.save()

for d in privacy_list:
user = User.get(User.c.username==d["username"])
if user:
d["user_id"] = user.id
print("create privacy record for user '%s'"%(d["username"]))
Privacy(**d).save()
else:
print("error: unknown user '%s'"%(d["username"]))

for d in moment_list:
user = User.get(User.c.username==d["username"])
if user:
d["user_id"] = user.id
print("create moment record for user '%s'"%(d["username"]))
Moment(**d).save()
else:
print("error: unknown user '%s'"%(d["username"]))

for d in comment_list:
user = User.get(User.c.username==d["username"])
if user:
d["user_id"] = user.id
d["to_id"] = User.get(User.c.username==d["to_username"]).id
print("create comment record for user '%s'"%(d["username"]))
Comment(**d).save()
else:
print("error: unknown user '%s'"%(d["username"]))

for d in publicnotice_list:
PublicNotice(**d).save()
28 changes: 28 additions & 0 deletionstests/demo/apps/apijson_demo/models.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
#coding=utf-8

from uliweb.orm import *

class Privacy(Model):
user_id = Reference("user")
certified = Field(bool)
phone = Field(str)
balance = Field(DECIMAL)
password = Field(str)
paypassword = Field(str)

class Moment(Model):
user_id = Reference("user")
date = Field(datetime.datetime, auto_now_add=True)
content = Field(TEXT)
picture_list = Field(JSON, default=[])

class Comment(Model):
user_id = Reference("user")
to_id = Reference("user")
moment_id = Reference("moment")
date = Field(datetime.datetime, auto_now_add=True)
content = Field(TEXT)

class PublicNotice(Model):
date = Field(datetime.datetime, auto_now_add=True)
content = Field(TEXT)
72 changes: 72 additions & 0 deletionstests/demo/apps/apijson_demo/settings.ini
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
[MODELS]
privacy = 'apijson_demo.models.Privacy'
comment = 'apijson_demo.models.Comment'
moment = 'apijson_demo.models.Moment'
publicnotice = 'apijson_demo.models.PublicNotice'

[APIJSON_MODELS]
user = {
"user_id_field" : "id",
"secret_fields" : ["password"],
"GET" : { "roles" : ["LOGIN","ADMIN","OWNER"] },
"HEAD" : { "roles" : ["LOGIN","ADMIN","OWNER"] },
"POST" : { "roles" : ["ADMIN"] },
"PUT" : { "roles" : ["ADMIN","OWNER"] },
"DELETE" : { "roles" : ["ADMIN"] },
}
privacy = {
"user_id_field" : "user_id",
"GET" : { "roles" : ["OWNER","ADMIN"] },
"HEAD" : { "roles" : ["OWNER","ADMIN"] },
"POST" : { "roles" : ["OWNER","ADMIN"] },
"PUT" : { "roles" : ["OWNER","ADMIN"] },
"DELETE" : { "roles" : ["OWNER","ADMIN"] },
}
moment = {
"user_id_field" : "user_id",
"GET" : { "roles" : ["OWNER","LOGIN","ADMIN","UNKNOWN"] },
"HEAD" : { "roles" : ["OWNER","LOGIN","ADMIN"] },
"POST" : { "roles" : ["OWNER","ADMIN"] },
"PUT" : { "roles" : ["OWNER","ADMIN"] },
"DELETE" : { "roles" : ["OWNER","ADMIN"] },
}
comment = {
"user_id_field" : "user_id",
"GET" : { "roles" : ["OWNER","LOGIN","ADMIN","UNKNOWN"] },
"HEAD" : { "roles" : ["OWNER","LOGIN","ADMIN"] },
"POST" : { "roles" : ["OWNER","ADMIN"] },
"PUT" : { "roles" : ["OWNER","ADMIN"] },
"DELETE" : { "roles" : ["OWNER","ADMIN"] },
}
publicnotice = {
"GET" : { "roles" : ["OWNER","LOGIN","ADMIN","UNKNOWN"] },
"HEAD" : { "roles" : ["OWNER","LOGIN","ADMIN","UNKNOWN"] },
"POST" : { "roles" : ["OWNER","ADMIN"] },
"PUT" : { "roles" : ["OWNER","ADMIN"] },
"DELETE" : { "roles" : ["OWNER","ADMIN"] },
}

[APIJSON_REQUESTS]
moment = {
"POST" :{
"ADD":{"@role": "OWNER"},
"DISALLOW" : ["id"],
"NECESSARY" : ["content"],
},
"PUT" :{
"ADD":{"@role": "OWNER"},
"NECESSARY" : ["id","content"],
},
}

comment = {
"POST" :{
"ADD" :{"@role": "OWNER"},
"DISALLOW" : ["id"],
"NECESSARY" : ["content"]
},
"PUT" :{
"ADD":{"@role": "OWNER"},
"NECESSARY" : ["id","content"],
},
}
1 change: 1 addition & 0 deletionstests/demo/apps/apijson_demo/static/readme.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
This directory is used to store static files.
1 change: 1 addition & 0 deletionstests/demo/apps/apijson_demo/templates/readme.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
This directory is used to store template files.
12 changes: 12 additions & 0 deletionstests/demo/apps/settings.ini
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
[GLOBAL]
DEBUG = False
DEBUG_CONSOLE = False
DEBUG_TEMPLATE = False

INSTALLED_APPS = [
'uliweb.contrib.orm',
'uliweb.contrib.auth',
'uliweb.contrib.rbac',
'uliweb_apijson.apijson',
'apijson_demo',
]
4 changes: 4 additions & 0 deletionstests/demo/requirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
six
SQLAlchemy
uliweb3
uliweb-apijson
Loading

[8]ページ先頭

©2009-2025 Movatter.jp