Example #1
0
def get_all_templates(obj):
    """Get all templates usable by an event/category."""
    category = (obj.category or Category.get_root()) if isinstance(
        obj, Event) else obj
    return set(
        DesignerTemplate.query.filter(
            DesignerTemplate.category_id.in_(categ['id']
                                             for categ in category.chain)))
Example #2
0
def get_default_ticket_on_category(category, only_inherited=False):
    if category is None:
        category = Category.get_root()
    if not only_inherited and category.default_ticket_template:
        return category.default_ticket_template
    parent_chain = category.parent_chain_query.options(
        joinedload('default_ticket_template')).all()
    return next((category.default_ticket_template
                 for category in reversed(parent_chain)
                 if category.default_ticket_template), None)
Example #3
0
    def _check_access(self):
        RHRegistrationsActionBase._check_access(self)

        # Check that template belongs to this event or a category that is a parent
        if self.template.owner == self.event:
            return
        valid_category_ids = self.event.category_chain or [
            Category.get_root().id
        ]
        if self.template.owner.id not in valid_category_ids:
            raise Forbidden
Example #4
0
 def _get_category(self, category_id):
     category = self._category_query.filter_by(id=category_id, is_deleted=False).one_or_none()
     if category is None and category_id == 0:
         category = Category.get_root()
     return category
Example #5
0
 def _get_category(self, category_id):
     category = self._category_query.filter_by(
         id=category_id, is_deleted=False).one_or_none()
     if category is None and category_id == 0:
         category = Category.get_root()
     return category