def recent_statuses(self, page=1, startdate=None, enddate=None): """Return the statuses for the team.""" user_ids = [u.id for u in self.users] statuses = Status.query.filter( Status.user_id.in_(user_ids), Status.reply_to==None).order_by( db.desc(Status.created)) return paginate(statuses, page, startdate, enddate)
def index(): """The home page.""" return render_template( 'index.html', statuses=paginate( Status.query.filter(Status.reply_to==None).order_by( db.desc(Status.created)), request.args.get('page', 1), startdate(request), enddate(request)),)
def get_statuses(): """Get all status updates. Returns id, user (the name), project name and timestamp of statuses. The amount of items to return is determined by the limit argument (defaults to 20): /api/v1/feed/?limit=20 An example of the JSON: { "1": { "user": "******", "content": "working on bug 123456", "project": "sumodev", "timestamp": "2013-01-11T21:13:30.806236" } } """ limit = request.args.get('limit', 20) statuses = Status.query.filter(Status.reply_to == None).\ order_by(db.desc(Status.created)).limit(limit) data={} for row in statuses: id = row.id created = row.created.isoformat() try: project_name = row.project.name except: project_name = None data[id] = (dict(author=row.user.name, content=row.content, timestamp=created, project=project_name)) return jsonify(data)
def recent_statuses(self, page=1, startdate=None, enddate=None): """Return the statuses for the user.""" statuses = self.statuses.filter(Status.reply_to==None).order_by( db.desc(Status.created)) return paginate(statuses, page, startdate, enddate)