Skip to content

Commit

Permalink
Generates releases feed per orgaizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricbonhomme committed Feb 15, 2018
1 parent 7614a8f commit cbefe41
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/web/templates/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ <h4>Description</h4>
<div>
<ol class="breadcrumb">
<li class="breadcrumb-item active">Projects</li>
<li class="breadcrumb-item active">
<a href="{{ url_for('organization_bp.recent_releases', organization_name=organization.name) }}"><i class="fa fa-rss" aria-hidden="true" title="Recent releases for {{ organization.name }}"></i></a>
</li>
</ol>
</div>
<div id="list-projects"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/web/templates/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h5>Recent CVEs</h5>
</div>

<div class="col-4">
<h5>Recent releases <a href="{{ url_for('project_bp.recent_releases', project_name=project.name) }}"><i class="fa fa-rss" aria-hidden="true"></i></a></h5>
<h5>Recent releases <a href="{{ url_for('project_bp.recent_releases', project_name=project.name) }}"><i class="fa fa-rss" aria-hidden="true" title="Recent releases for {{ project.name }}"></i></a></h5>
<div id="project-releases" class="list-group"></div>
</div>
</div>
Expand Down
22 changes: 21 additions & 1 deletion src/web/views/organization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from flask import Blueprint, render_template, abort
from flask import Blueprint, render_template, request, abort
from werkzeug.contrib.atom import AtomFeed

from bootstrap import db
from web.models import Organization

organization_bp = Blueprint('organization_bp', __name__,
Expand All @@ -19,3 +21,21 @@ def get(organization_name=None):
if organization is None:
abort(404)
return render_template('organization.html', organization=organization)


@organization_bp.route('/<string:organization_name>/releases.atom', methods=['GET'])
def recent_releases(organization_name=None):
"""Generates a feed for the releases."""
organization = Organization.query. \
filter(Organization.name==organization_name).first()
if organization is None:
abort(404)
feed = AtomFeed('Recent releases for {}'.format(organization.name),
feed_url=request.url, url=request.url_root)
for project in organization.projects:
for release in project.releases:
feed.add(release.version, release.changes,
id=release.id,
url=release.release_url,
updated=release.published_at)
return feed.get_response()

0 comments on commit cbefe41

Please sign in to comment.