本文整理汇总了Python中models.Project.create方法的典型用法代码示例。如果您正苦于以下问题:Python Project.create方法的具体用法?Python Project.create怎么用?Python Project.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Project
的用法示例。
在下文中一共展示了Project.create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def create_project(project_id, project_description):
"""Takes arguments and create a new project."""
db.connect()
Project.create(project_id=project_id, project_description=project_description)
db.close()
示例2: test_create_project_no_duplicate
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def test_create_project_no_duplicate(self):
"""Make sure you can't create projects with duplicate IDs."""
Project.create(project_id='001', project_description='Testing purpose.')
from peewee import IntegrityError
with self.assertRaises(IntegrityError):
Project.create(project_id='001', project_description='This could be the same.')
# Delete the instance created
q = Project.delete().where(Project.project_id == '001')
q.execute()
示例3: test_create_outgoing
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def test_create_outgoing(self):
"""Create an outgoing record."""
Category.create(category_id='001', description='Testing Stock')
Project.create(project_id='001', project_description="Testing")
Role.create(role_name='Admin')
User.create(first_name='Jay', second_name='Palm', phone='9783978223', role='Admin', username='JayPalm',
password='jfresh13', email='[email protected]')
create_stock('001', 'Testing stock', 1, '001', 9.99)
create_outgoing_stock(stock='001', project_id='001', date="2015-07-22", quantity='7', username='JayPalm')
OutgoingStock.get(OutgoingStock.stock == '001').delete_instance()
Stock.get(Stock.category == '001').delete_instance()
User.get(User.username == 'JayPalm').delete_instance()
Role.get(Role.role_name == 'Admin').delete_instance()
Project.get(Project.project_id == '001').delete_instance()
Category.get(Category.category_id == '001').delete_instance()
示例4: rpc_post_create_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def rpc_post_create_project(self, project, description=""):
p = Project.create(self.user, project, description)
if p:
res = {"id": p.ph_id, "name": p.name}
else:
res = {"status": "error", "message": "couldnt create the project"}
return res
示例5: setUp
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.projkwargs = {'name' : 'test'}
self.project = Project.create(**self.projkwargs)
self.kwargs = {'parent' : self.project,
'title' : 'test',
'description' : 'desctest',
'notes' : []}
示例6: put
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def put(self):
args = parser.parse_args()
new_project = Project.create(name=args['name'],
git_repo=args['git_repo'],
branch=args['branch'])
if new_project.id:
return model_to_dict(new_project), 201
else:
return 500
示例7: projects
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def projects():
req = request.get_json()
message = ""
try:
page = req['page']
page_size = req['pageSize']
except (TypeError, KeyError):
page = 1
page_size = 20
if request.method == 'POST':
try:
request_error = False
title = req['title']
comments = req['comments']
stacks = req['stacks']
probe_type = req['probeType']
except KeyError:
request_error = True
if request_error:
return jsonify({ 'message': 'Insufficient information to create project' }), 400
try:
project = Project.create(title=title, comments=comments, probe_type=probe_type)
if req['markerOptions']:
marker_options = req['markerOptions']
for marker_name in marker_options:
try:
marker_option = MarkerOption.get(MarkerOption.name == marker_name)
ProjectMarkerOption.create(project = project, marker_option = marker_option)
except Exception as ex:
print("line 74")
print ex
if req['users']:
users = req['users']
for user in users:
try:
ProjectUser.create(app_user = user['id'], project = project)
except Exception as ex:
print ex
for stack in stacks:
try:
project_stack = ProjectStack.create(project=project, stack = stack['stackId'])
probe_setting = stack['probeSettings']
probe_position = json.loads(probe_setting['position'])
ProbeSetting.create(x_offset=int(probe_position['xOffset']),
y_offset=int(probe_position['yOffset']),
project_stack=project_stack,
label=probe_position['label']
)
except Exception as ex:
print ex
message = "Project created"
except Exception as ex:
print ex
projects = (Project.select()
.order_by(Project.created_date.desc()))
# .paginate(page, page_size))
return jsonify({
'message': message,
'projects': [project.serialized for project in projects],
'projectCount': SelectQuery(models.Project).count()
}), 201
示例8: test_init
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def test_init(self):
self.project = Project.create(**self.kwargs)
self.assertTrue(self.project.name == 'test')
示例9: create_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import create [as 别名]
def create_project():
if authenticate():
project = request.form
error = False
title = request.form['title'].strip() if request.form['title'] != None else None
if title:
if re.search("^[ a-zA-Z0-9\,\?\!]+$", title) == None:
flash('Invalid characters detected in title')
error = True
else:
flash('Title cannot be empty')
error = True
title_desc = request.form['title_desc'].strip()
if title_desc:
title_desc = title_desc.replace("\r","")
num_matches = len(re.findall("^[ a-zA-Z0-9\.\?\,\!/]+$",title_desc,re.MULTILINE))
num_lines = len(list(filter(remove_blanks,title_desc.split("\n"))))
if num_matches != num_lines:
flash('Invalid characters detected in title description')
error = True
else:
flash('Title description cannot be blank')
error = True
description = request.form['description'].strip()
if description:
regex = re.compile("^[ a-zA-Z0-9\.\?\,\!/]+$", re.MULTILINE)
description = description.replace("\r","")
num_matches = len(regex.findall(description))
num_lines = len(list(filter(remove_blanks,description.split("\n"))))
if num_matches != num_lines:
flash('Invalid characters detected in project description')
error = True
if request.form['tags'].strip() != "":
if re.findall("^[ a-zA-Z0-9\,\.]+$",request.form['tags']) == []:
flash('Invalid characters detected in tags')
error = True
learned_points = request.form['learned'].strip()
if learned_points:
learned_points = learned_points.replace("\r","")
num_matches = len(re.findall("^[ a-zA-Z0-9\.\?\,\!/]+$",learned_points,re.MULTILINE))
num_lines = len(list(filter(remove_blanks,learned_points.split("\n"))))
if num_matches != num_lines:
flash('Invalid characters detected in learning points')
error = True
else:
learned_points = learned_points.replace(',','+')
learned_points = learned_points.replace('\n',',')
else:
flash('What I learned cannot be empty')
error = True
if not error:
try:
project = Project.create(
title=request.form['title'],
title_desc=request.form['title_desc'],
description=request.form['description'],
tags=request.form['tags'],
learned=learned_points,
created_at=datetime.datetime.now()
)
except IntegrityError:
flash('That title is already taken')
error = True
else:
flash('Project description cannot be empty')
error = True
if error:
return render_template('projects/new.html', project=project)
else:
return redirect(url_for('single_project', project_id=project.id))
else:
flash('Not authorized to do that')
return redirect(url_for('projects'))