当前位置: 首页>>代码示例>>Python>>正文


Python Project.create方法代码示例

本文整理汇总了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()
开发者ID:dsantosp12,项目名称:NapAdmin,代码行数:9,代码来源:project.py

示例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()
开发者ID:dsantosp12,项目名称:NapAdmin,代码行数:13,代码来源:tests.py

示例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()
开发者ID:dsantosp12,项目名称:NapAdmin,代码行数:17,代码来源:tests.py

示例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
开发者ID:ciju,项目名称:perf-hier,代码行数:9,代码来源:perf_hier.py

示例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' : []}
开发者ID:ci-project,项目名称:ci-project,代码行数:12,代码来源:tests.py

示例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
开发者ID:joepreludian,项目名称:deployer-ci,代码行数:14,代码来源:model_api.py

示例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
开发者ID:BlaiseGratton,项目名称:DataAnalysisNgin,代码行数:63,代码来源:project_routes.py

示例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')
开发者ID:ci-project,项目名称:ci-project,代码行数:5,代码来源:tests.py

示例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'))
开发者ID:brendanWeb,项目名称:old-brendanhenderson.com,代码行数:76,代码来源:views.py


注:本文中的models.Project.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。