Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Product fixed again. Fixed a bug with home page...

  • Loading branch information...
commit 2608fbcc3f89ac3571d180c23865fdfca71e635e 1 parent 5358830
Seb Insua authored
2  modules/app/controller/home.py
View
@@ -9,6 +9,6 @@ def show_home():
uuid = session['uuid']
from mu.model.repository.user import fetch_user_with_uuid
user = fetch_user_with_uuid(uuid)
- username = user.username
+ username = user.username if user else None
return render_template("home.html", username=username)
4 modules/app/controller/product.py
View
@@ -40,6 +40,10 @@ def add_product_to_content_author(product_type, agent=None):
'product_medium_id' : request.form.get('medium')
}
+ print "ProductInfo is: "
+ import pprint
+ pprint.pprint(product_info)
+
product_domain.add_product(**product_info)
return render_template('product/add_product.html',
7 modules/app/model/domain/product.py
View
@@ -9,14 +9,11 @@ class ProductDomain:
def add_product(self, agent_name, event_release_date, \
product_title, product_type_id=None, product_status_id=None, \
product_medium_id=None, content_owner_name=None):
- # event_type_id needs to be set depending on the product_type_id
- event_type = get_event_type_from_product_type_id(product_type_id)
- event_type_id = event_type.event_type_id
# Add an Event
from mu.model.entity.event import Event
# TODO: Pick the correct release date field depending on the data.
- event = Event(event_type_id, predicted_textual_release_date=event_release_date)
+ event = Event(predicted_textual_release_date=event_release_date)
event_id = add_event(event)
# Add a Product
@@ -31,7 +28,7 @@ def add_product(self, agent_name, event_release_date, \
# TODO: musicbrainz_mbid, start_date and end_date can be None or fetched from musicbrainz.
agent_id = add_agent(agent)
# TODO: For sure the database can be improved again... This is weird.
- link_event_to_agent(agent_id, event_id, agent_type_id)
+ link_product_to_agent(agent_id, product_id, agent_type_id)
# Optionally add a ContentOwner
if content_owner_name:
2  modules/app/model/entity/service.py
View
@@ -57,7 +57,7 @@ def __init__(self, service_id, agent_id, agent_type_id, agent_order=None):
class ServiceType(db.Model):
__tablename__ = 'ServiceType'
- product_type_id = db.Column(db.Integer, primary_key=True)
+ service_type_id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), unique=True, nullable=False)
def __init__(self, name):
9 modules/app/model/repository/agent.py
View
@@ -5,8 +5,7 @@ def add_agent(agent):
db.session.commit()
return agent.agent_id
-def link_event_to_agent(agent_id, event_id, agent_type_id):
- from mu.model.entity.agent import AgentEvent
- agent_event = AgentEvent(agent_id, event_id, agent_type_id)
- # TODO: What about the content author product type!
- return agent_event.agent_event_id
+def link_product_to_agent(agent_id, product_id, agent_type_id):
+ from mu.model.entity.product import ProductAgent
+ product_agent = ProductAgent(product_id, agent_id, agent_type_id)
+ return product_agent.product_agent_id
15 modules/app/model/repository/event.py
View
@@ -4,18 +4,3 @@ def add_event(event):
db.session.add(event)
db.session.commit()
return event.event_id
-
-def get_event_type_from_product_type_id(product_type_id):
- from mu.model.entity.product import ProductType
- from mu.model.entity.event import EventType
-
- pt_query = db.session.query(ProductType).filter(ProductType.product_type_id == product_type_id)
- product_type = pt_query.one()
-
- if product_type.name == 'Event':
- et_query = db.session.query(EventType).filter(EventType.name == 'Performance')
- else:
- et_query = db.session.query(EventType).filter(EventType.name == 'Release')
-
- event_type = et_query.one()
- return event_type
Please sign in to comment.
Something went wrong with that request. Please try again.