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


Python Project.get方法代码示例

本文整理汇总了Python中models.Project.get方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get方法的具体用法?Python Project.get怎么用?Python Project.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Project的用法示例。


在下文中一共展示了Project.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
 def delete(self, key):
     if auth.user_is_admin():
         Project.get(key).delete()
     else:
         Messages.add('Only and administrator may delete projects. This ' +
                      'incident has been logged.')
     return self.redirect('/projects')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:9,代码来源:back.main.py

示例2: test_create_outgoing

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [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

示例3: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
	def	post(self):
		action = self.request.get('action', 'add')
		if action == 'add':
			if len(self.request.get('name'))<2:
				raise Exception("project name must be at least 2 characters long")
			if len(self.request.get('currency'))<1:
				raise Exception("project currency must be at least one character long")
			# create the project and return the new location to go to
			project = Project(name=self.request.get('name'), currency=self.request.get('currency'))
			project.put()
			# add access rights for this user to the new project
			rights = ProjectRights(project=project, user=users.GetCurrentUser(), right=Security.Right_Owner)
			rights.put()
			# redirect to summary
			self.response.out.write("/summary?project=%(key)s" % {'key':project.key()})
		elif action == 'delete':
			# remove me from the projects right list
			project = Project.get(self.request.get('project', ''))
			if (not project):
				raise Exception("Unknown project!")
			# check rights of current user for this project, and deny access if not permitable
			rights = ProjectRights.gql("WHERE user=:user and project=:project", user=users.get_current_user(), project=project).get()
			if rights:
				rights.delete()
			# redirect to my page
			self.response.out.write("/")
		else:
			raise Exception("Unknown action '%(action)s'!" % {'action':action})
开发者ID:realthargor,项目名称:urlaubsabrechnung,代码行数:30,代码来源:ProjectsHandler.py

示例4: update_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def update_project(project_id):
    new_project = request.get_json()
    try:
        project = Project.get(Project.id == project_id)
    except models.DoesNotExist:
        return jsonify({ 'message': 'Project not found' }), 400
    if new_project['id'] != project.id:
        return jsonify({ 'message': 'Cannot update project at this url' }), 400
    try:
        if new_project['markerOptions']:
            marker_options = new_project['markerOptions']
            for marker_name in marker_options:
                try:
                    marker_option = MarkerOption.get(MarkerOption.name == marker_name)
                    ProjectMarkerOption.get(ProjectMarkerOption.project == project.id,
                                            ProjectMarkerOption.marker_option == marker_option.id)
                except models.DoesNotExist:
                    ProjectMarkerOption.create(project = project, marker_option = marker_option)
        if new_project['users']:
            users = new_project['users']
            for user in users:
                try:
                    project_user = ProjectUser.get(ProjectUser.app_user == user['id'],
                                                    ProjectUser.project == project)
                except models.DoesNotExist:
                    ProjectUser.create(app_user = user['id'], project = project)
        if new_project['stacks']:
            stacks = new_project['stacks']
            with db.atomic():
                for stack in stacks:
                    try:
                        project_stack = ProjectStack.get(ProjectStack.stack == stack['id'],
                                                        ProjectStack.project == project)
                    except models.DoesNotExist:
                        project_stack = ProjectStack.create(project=project, stack = stack['id'])
                        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']
                                        )
        message = "Project updated"
    except Exception as ex:
        print ex
    project = Project.get(Project.id == project_id)
    return jsonify({ 'message': 'Project updated', 'project': project.deep_serialized() }), 200
开发者ID:BlaiseGratton,项目名称:DataAnalysisNgin,代码行数:49,代码来源:project_routes.py

示例5: delete_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def delete_project(project_id):
    project = Project.get(Project.id == project_id)
    if project:
        project_title = project.title
        project.delete_instance(recursive=True)
        return jsonify({ 'message': 'Successfully deleted "{}"'.format(project_title) }), 200
    else:
        return jsonify({ 'message': 'Unable to delete project' }), 400
开发者ID:BlaiseGratton,项目名称:DataAnalysisNgin,代码行数:10,代码来源:project_routes.py

示例6: post

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
 def post(self):
     project_id = self.request.get('project-id')
     api_token = self.request.get('api-token')
     project = Project.get()
     project.project_id = project_id
     project.api_token = api_token
     project.put()
     self.redirect('/project')
开发者ID:gklopper,项目名称:Tracker,代码行数:10,代码来源:project.py

示例7: delete_project

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def delete_project(project_id):
    if authenticate():
        try:
            project = Project.get(Project.id == project_id)
            return render_template('projects/delete.html', project=project)
        except Project.DoesNotExist:
            return redirect(url_for('projects'))
    else:
        flash('Not authorized to do that')
        return redirect(url_for('projects'))
开发者ID:brendanWeb,项目名称:old-brendanhenderson.com,代码行数:12,代码来源:views.py

示例8: save

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def save(name):
    project = Project.get(name=name)
    if not project:
        return 'No', 404

    project.update(request.form)
    project.save()

    flash('Saved')
    return redirect('/projects/%s/'%name)
开发者ID:muromec,项目名称:enodev.ikari,代码行数:12,代码来源:views.py

示例9: task

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def task(op, project_id, push_id):
    f = globals()['task_%s' % op]
    project = Project.get(name=project_id)
    if not project:
        # XXX: cry to log
        return

    s = partial(push_status, push_id, project)
    s._id = push_id
    f(project, s)
开发者ID:muromec,项目名称:enodev.ikari,代码行数:12,代码来源:task.py

示例10: vote

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
 def vote(self, key):
     if not auth.logged_in():
         return self.redirect('/projects')
     project = Project.get(key)
     if project.has_voted(auth.current_user()):
         project.remove_vote(auth.current_user())
         project.put()
     else:
         project.vote(auth.current_user())
         project.put()
     return self.redirect('/projects')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:13,代码来源:back.main.py

示例11: show

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def show(name):
    project = Project.get(name=name)
    if not project:
        return "No", 404

    (project._field('status')).locked = True
    (project._field('rev')).locked = True

    status = rstatus_name(name)

    return render_template('project_show.html',
            project=project, status=status)
开发者ID:muromec,项目名称:enodev.ikari,代码行数:14,代码来源:views.py

示例12: claim

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
 def claim(self, key):
     user = auth.User(auth.current_user())
     group = user.group
     if group.owner.user_id() == auth.current_user().user_id():
         project = Project.get(key)
         group.project = project
         group.put()
         return self.redirect('/groups/%s' % group.key())
     else:
         Messages.add('You are not the owner of your group. Only the ' +
                      'owner of the group may select a project.')
         return self.redirect('/projects')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:14,代码来源:back.main.py

示例13: copy_key

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
def copy_key(name, push_id=None):
    project = Project.get(name=name)

    project.ssh_key = ops.fetch_key(name)
    project.save()

    if not push_id:
        return

    push(push_id, {
        "typ": "project.key",
        "key": project.ssh_key,
        "project": project.name,
    })
开发者ID:muromec,项目名称:enodev.ikari,代码行数:16,代码来源:task.py

示例14: vote

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
    def vote(self, key):
        """Votes for a project.

        This action removes the user's vote from the project if the user had
        already voted for it.
        """
        if not auth.logged_in():
            return self.redirect('/projects')
        project = Project.get(key)
        if project.has_voted(auth.current_user()):
            project.remove_vote(auth.current_user())
            project.put()
        else:
            project.vote(auth.current_user())
            project.put()
        return self.redirect('/projects')
开发者ID:ryleyherrington,项目名称:app_hackathon,代码行数:18,代码来源:main.py

示例15: _create_new_story

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get [as 别名]
    def _create_new_story(self, event):
        logging.info('Creating story')
        story = Story(story_id=event.story_id, name=event.story_title)
        story.put()

        project = Project.get()

        api_url = 'http://www.pivotaltracker.com/services/v3/projects/{PROJECT_ID}/stories/{STORY_ID}/notes'.replace('{PROJECT_ID}', project.project_id).replace('{STORY_ID}', story.story_id)
        comment_xml = '<note><text>http://{APP_ID}.appspot.com/s/{STORY_ID}</text></note>'.replace('{APP_ID}', os.environ['APPLICATION_ID']).replace('{STORY_ID}', story.story_id)

        logging.info('Api url: ' + api_url)
        logging.info('Comment xml: ' + comment_xml)

        #post a comment back to pivotal tracker
        result = urlfetch.fetch(url=api_url,
                                payload=comment_xml,
                                method=urlfetch.POST,
                                headers={'Content-Type': 'application/xml', 'X-TrackerToken': project.api_token})
        logging.info('Result of API call: ' + result.content)
开发者ID:gklopper,项目名称:Tracker,代码行数:21,代码来源:pivotaltracker.py


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