Permalink
Browse files

* Block access to adding a product type that is not supported.

* Titles support.
  • Loading branch information...
1 parent 53fe5d8 commit 1865cf7b169e18e0a288230c6649dd3d68172e2f @sebinsua committed Apr 6, 2012
@@ -47,8 +47,19 @@ def get_products(product_type=None):
# Accept plural but convert to singular...
if product_type and product_type.endswith('s'): # urls are pluralised but data is singular!
product_type = product_type[:-1]
- if product_type in ['release', 'product']:
+ if product_type == 'release':
product_type = None # We want to get everything out in this case.
products = fetch_products(product_type)
return products
+
+ @staticmethod
+ def is_valid_product_type(product_type=None):
+ if product_type == 'release':
+ return True
+
+ try:
+ ProductType.query.filter_by(name=product_type).one()
+ return True
+ except:
+ return False
@@ -1,12 +1,14 @@
{% macro render_field(field) %}
-<dt>{{ field.label }}</dt>
-<dd>{{ field(**kwargs)|safe }}
- {% if field.errors %}
- <ul class="errors">
- {% for error in field.errors %}
- <li>{{ error }}</li>
- {% endfor %}
- </ul>
+ {% if field.type != 'HiddenField' %}
+ <dt>{{ field.label }}</dt>
+ <dd>{{ field(**kwargs)|safe }}
+ {% if field.errors %}
+ <ul class="errors">
+ {% for error in field.errors %}
+ <li>{{ error }}</li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </dd>
{% endif %}
-</dd>
{% endmacro %}
@@ -1,11 +1,22 @@
{% from "helper/core.html" import output_flashed_messages %}
{% from "helper/form.html" import render_field %}
{% extends layout_template if layout_template is defined else "layout/main.html" %}
+
{% set active_page = 'releases' %}
+{% if product_type == 'ep' %}
+{% set title = 'Add EP' %}
+{% else %}
+{% set title = 'Add ' + product_type|capitalize %}
+{% endif %}
+
+{% block head_title %}
+ -
+ {{ title }}
+{% endblock %}
{% block content %}
<div class="container">
- <h1>Product</h1>
+ <h2>{{ title }}</h2>
{{ output_flashed_messages() }}
<form method="POST" action="/add/{{ product_type }}{% if agent %}/to/{{ agent }}{% endif %}">
{{ form.hidden_tag() }}

0 comments on commit 1865cf7

Please sign in to comment.