-
-
Save amcgregor/f173ceff67bcd1eab610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JobsController(Generic): | |
__model__ = Job | |
__order__ = '-id' | |
__form__ = manage_form | |
__metadata__ = dict( | |
area = 'job', | |
icon = 'rocket', | |
singular = L_("Job"), | |
plural = L_("Jobs"), | |
subtitle = L_("Job postings.") | |
) | |
# Column Definitions | |
title = SelectableTranslatedPrimaryColumn('title', L_("Title"), 4) | |
reference = Column('reference', L_("Reference"), 2) | |
company = ReferenceColumn('company', L_("Company"), 3) | |
state = StateColumn('state', L_("State"), 2) | |
daterange = Column(('published', 'retracted'), "", 0, condition=False) | |
# Security Configuraiton of Existing Views | |
list = Generic.list.clone(condition=authenticated) | |
create = Generic.create.clone(condition=authenticated) | |
read = Generic.read.clone(condition=authenticated, template='rita.job.template.view') | |
update = Generic.update.clone(condition=authenticated) # TODO: owner of record | |
delete = Generic.delete.clone(condition=is_alice) # TODO: Validate unused state. | |
# Quick Search Indexes | |
slug_idx = Index('short') | |
reference_idx = Index('reference', typeahead=True) | |
title_idx = Index('title', ('en', 'fr'), typeahead=True) | |
address_idx = Index('address', ('address', 'city', 'region', 'country', 'postal')) | |
url_idx = Index('site') | |
company_idx = ReferenceIndex('company', ('name.en', 'name.fr'), join=Company) | |
# Meta Attributes | |
@property | |
def __query__(self): | |
"""Perform basic security by filtering the results.""" | |
query = super(JobsController, self).__query__ | |
u = user._current_obj() | |
if is_administrator: | |
return query | |
return query.filter(company__in=u.companies) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment