Page Source

from utils.display import Display, Database
from utils.controls import *
from utils.web_exc import WebError
import queries, debugging
from config import docroot
import string, os

class FacultyInterestsDisplay(Display, Database):
  multiple_controls = [
    LinkControl(field="login", url="%(person!login)s", subcontrol=FieldControl("name")),
    "<blockquote>", LongFieldControl("research"), "</blockquote>"

  def __init__(self, req):
    Display.__init__(self, req)

  def make_page(self, page):
    page.append("""<h1>%s</h1>""" % self.get_multiple_title())

  def get_multiple_title(self):
    return "Faculty Research Interests"

  def db_rows(self):
    return self.query.count()

  def is_multiple(self):
    return 1                            # always plural

  def db_query(self):
    # OK, so we sorta hardcode this by listing the grouping named 'Faculty'
    q = queries.Select(tables=["groupings", "grouping_priorities", "titles", "people"],
                       columns={ 'research' : 'people.research',
                                 'login' : 'people.login',
                                 'name' : "concat(people.fname, ' ', people.lname)" },
                       order="lname, fname, mname",
                       distinct = 1,
                       research is not NULL and
                       research != '' and
              = 'Faculty' and
              = and
                       titles.title LIKE groupings.title and
                       titles.context LIKE groupings.context and
                       titles.login = people.login
    self.query = q

  def db_fetch(self):
    self.fields = self.query.fetch()
    return self.fields

def new(req):
  return FacultyInterestsDisplay(req)