Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
#40 Started individual project pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jordannewport committed Mar 17, 2018
1 parent 2a6807e commit 4edf54b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions acmwebsite/controllers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,35 @@
from acmwebsite.lib.base import BaseController
from acmwebsite.model import DBSession, Project

__all__ = ['ProjectsController']
class ProjectController(BaseController):
def __init__(self, project):
self.project = project

@expose('acmwebsite.templates.project')
def _default(self):
"""Handle the project's page."""
return dict(page='project', p=self.project)

@expose()
def picture(self):
redirect(DepotManager.url_for(self.project.image.path))

class ProjectsController(BaseController):
"""Root controller for listing all projects"""

@expose('acmwebsite.templates.projects')
def index(self):
return dict(page='projects', projects=DBSession.query(Project).all())

@expose()
def _lookup(self, pid=None, *args):
# TODO: change to use textual ID instead of project id
project = None
if pid:
project = DBSession.query(Project) \
.filter(Project.id == pid) \
.one_or_none()
if not project:
abort(404, "No such project")
return ProjectController(project), args
14 changes: 14 additions & 0 deletions acmwebsite/templates/project.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html py:strip=""
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">

<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - ${p}</title>
</head>

<body py:block="body" py:strip="True">
<h1 class="page-header">${p}</h1>
</body>
</html>

0 comments on commit 4edf54b

Please sign in to comment.