From 4edf54bb4ceca83de061f41d586b8655431450cc Mon Sep 17 00:00:00 2001 From: Jordan Newport Date: Sat, 17 Mar 2018 17:19:14 -0600 Subject: [PATCH] #40 Started individual project pages --- acmwebsite/controllers/project.py | 25 +++++++++++++++++++++++++ acmwebsite/templates/project.xhtml | 14 ++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 acmwebsite/templates/project.xhtml diff --git a/acmwebsite/controllers/project.py b/acmwebsite/controllers/project.py index 0dff768..bb9e3cc 100644 --- a/acmwebsite/controllers/project.py +++ b/acmwebsite/controllers/project.py @@ -5,6 +5,19 @@ 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""" @@ -12,3 +25,15 @@ class ProjectsController(BaseController): @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 \ No newline at end of file diff --git a/acmwebsite/templates/project.xhtml b/acmwebsite/templates/project.xhtml new file mode 100644 index 0000000..37317cb --- /dev/null +++ b/acmwebsite/templates/project.xhtml @@ -0,0 +1,14 @@ + + + + + + Mines ACM - ${p} + + + +

${p}

+ +