Пример #1
0
def tasks_list(project_id):
    pro = Project.objects.get(pk=project_id)
    tasks = Task.objects(project=pro)
    u = User.objects.get(pk = session['user_id'])
    project_list = Project.objects(user =u)

    return render_template('tasks/list.html',project=pro,tasks=tasks,pro=project_list)
Пример #2
0
def get_author_projects(author_id):
    """Retrieves a list of projects created by the author matching the id author_id.
    Pagination parameters page and per_page can be passed in the URL. They default
    respectively to 1 and 10 if omitted.
    """
    return paginate(resource_name='projects', endpoint='get_author_projects',
                    objects=Project.objects(author_id=author_id),
                    endpoint_params={'author_id': author_id})
Пример #3
0
def delete_project(project_id):
    """Deletes the project matching the id project_id."""
    project = Project.objects(id=project_id).get()
    project.delete()

    # Removes the project from the list of the author projects.
    Author.objects(id=project.author_id).update_one(pull__projects=project.id)

    return jsonify(project.to_dict())
Пример #4
0
def update_project(project_id):
    """Updates the project matching the id project_id.
    Only the parameters to update or to add should be passed in the request body.
    """
    project = Project.objects(id=project_id).get()
    patched = Project(**dict(chain(project.to_dict().items(), request.get_json().items())))
    patched.save()

    return jsonify(patched.to_dict())
	def decorated(*args, **kwargs):
		if 'project_slug' in kwargs:
			slug = kwargs['project_slug']
			project = Project.objects(slug=slug).first_or_404()
		if project:
			del kwargs['project_slug']
			kwargs['project'] = project
			return f(*args, **kwargs)
		else:
			abort(404) 
Пример #6
0
def system_stats():
    ''' calculates and prints info about the system
    usage:
        $ . /path/to/venv/bin/activate
        (venv)$ python
        >> import application
        >> application.controllers.system_stats()
        there are 1234 entries in the system
    '''
    # initialize the mongoengine connection
    mongo_config = app.config['MONGO_CONFIG']
    mongodb_uri = 'mongodb://'
    if mongo_config['dbuser'] and mongo_config['dbpassword']:
        mongodb_uri += '%s:%s@' % (mongo_config['dbuser']
                , mongo_config['dbpassword'])
    mongodb_uri += '%s/%s' % (mongo_config['hosts'], mongo_config['db_name'])
    connect(mongo_config['db_name'], host=mongodb_uri)

    projects = Project.objects()
    total_entries = 0
    total_points = 0
    for project in projects:
        schema = project.ordered_schema
        entries = Entry.objects(project=project)

        # count the points
        for entry in entries:
            # drop non-uniques or hidden
            if not entry.unique or not entry.visible:
                continue
            
            total_entries += 1

            # count datapoints
            for header in schema:
                if header.name in entry.values:
                    if entry['values'][header.name] != None:
                        total_points += 1

    print 'there are %s entries in the system' % total_entries
    print 'there are %s datapoints in the system' % total_points
Пример #7
0
def project(project_id):
    pro = Project.objects.get(pk=project_id)
    u = User.objects.get(pk = session['user_id'])
    project_list = Project.objects(user =u)
    return render_template('project.html',project=pro,pro=project_list)
Пример #8
0
 def get(self, tag):
     projects = Project.objects(tags=tag)
     return render_template('projects/list.html', projects=projects)
Пример #9
0
 def get(self):
     projects = Project.objects(publish=True)
     return render_template('projects/list.html', projects=projects)
Пример #10
0
def get_project(project_id):
    """Retrieves the project matching the id project_id."""
    return jsonify(Project.objects(id=project_id).get().to_dict())