Skip to content

Commit

Permalink
re TireSwingSoftware#9 Fixed two cases in tests_svc where the unused …
Browse files Browse the repository at this point in the history
…attribute was still being passed a value.

re TireSwingSoftware#34 updated name attributes to match between Session and SessionTemplate models. Also removed the automatic application of most template values to a new session. The system was never meant to work that way, but instead, the UI should present the template values as defaults and allow the user to change them. If the UI implementation sees it fit to skip this part, it is welcome to do so, but let's not assume it wants to.

removed a few stray product line attributes being passed in event creation, which somehow slipped back into the test suite recently. This requirement was removed in issue TireSwingSoftware#6
  • Loading branch information
mhrivnak committed Nov 4, 2011
1 parent cefe57c commit cc78685
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 1,285 deletions.
72 changes: 37 additions & 35 deletions pr_services/event_system/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def __init__(self):
'default_price' : 'get_general',
'end' : 'get_time',
'evaluation' : 'get_foreign_key',
'fullname' : 'get_general',
'modality' : 'get_general',
'name' : 'get_general',
'paypal_url' : 'get_paypal_url_from_session',
'shortname' : 'get_general',
'start' : 'get_time',
'status' : 'get_general',
'title' : 'get_general',
Expand All @@ -64,8 +65,9 @@ def __init__(self):
'session_template' : 'set_foreign_key',
'default_price' : 'set_general',
'end' : 'set_time',
'fullname' : 'set_general',
'modality' : 'set_general',
'name' : 'set_general',
'shortname' : 'set_general',
'start' : 'set_time',
'status' : 'set_general',
'title' : 'set_general',
Expand All @@ -84,68 +86,69 @@ def __init__(self):

@service_method
def create(self, auth_token, start, end, status, confirmed, default_price,
event, optional_attributes=None):
event, shortname, fullname, optional_attributes=None):
"""
Create a new Session
@param start Start time as ISO8601 string
@param start Start time as ISO8601 string
@type start string
@param end End time as ISO8601 string
@param end End time as ISO8601 string
@type end string
@param status String: one of 'active', 'pending', 'canceled', 'completed'
@param confirmed is this Session confirmed?
@param status String: one of 'active', 'pending', 'canceled', 'completed'
@param confirmed is this Session confirmed?
@type confirmed bool
@param default_price Default Price in cents
@param event Foreign Key for an event
@param optional_attributes Optional attribute values indexed by name
@return Instance of Session
dict with new primary key indexed as 'id'
@param default_price Default Price in cents
@param event Foreign Key for an event
@param shortname human-readable short name
@type shortname string
@param fullname human-readable long name
@type fullname string
@param optional_attributes Optional attribute values indexed by name
@return Instance of Session
dict with new primary key indexed as 'id'
"""

if optional_attributes is None:
optional_attributes = {}

new_session = self._create(auth_token, start, end, status, confirmed, default_price,
event, optional_attributes)
event, shortname, fullname, optional_attributes)
self.authorizer.check_create_permissions(auth_token, new_session)
return new_session

def _create(self, auth_token, start, end, status, confirmed, default_price,
event, optional_attributes=None):
event, shortname, fullname, optional_attributes=None):
"""
Create a new Session
@param start Start time, ISO8601 string
@param end End time, ISO8601 string
@param status String: one of 'active', 'pending', 'canceled', 'completed'
@param confirmed Boolean: is this Session confirmed?
@param default_price Default price for the Session in US cents
@return Instance of Session
@param start Start time, ISO8601 string
@param end End time, ISO8601 string
@param status String: one of 'active', 'pending', 'canceled', 'completed'
@param confirmed Boolean: is this Session confirmed?
@param default_price Default price for the Session in US cents
@param event Foreign Key for an event
@param shortname human-readable short name
@type shortname string
@param fullname human-readable long name
@type fullname string
@return Instance of Session
"""

if optional_attributes is None:
optional_attributes = {}

actor = auth_token.user
b = facade.managers.BlameManager().create(auth_token)
start = pr_time.iso8601_to_datetime(start)
end = pr_time.iso8601_to_datetime(end)
name = str(end.year)+str(end.month)+str(end.day)
new_session = self.my_django_model(start = pr_time.iso8601_to_datetime(start), end=end, name=name,
new_session = self.my_django_model(start=start, end=end,
status=status, confirmed=confirmed, default_price=default_price,
blame=b)
if 'session_template' in optional_attributes:
the_session_template = self._find_by_id(optional_attributes['session_template'], facade.models.SessionTemplate)
if the_session_template.shortname:
new_session.name = the_session_template.shortname + name
if the_session_template.description is not None:
new_session.description = the_session_template.description
if (the_session_template.price is not None) and (new_session.default_price is None):
new_session.default_price = the_session_template.price
if (the_session_template.modality is not None) and (new_session.modality is None):
new_session.modality = the_session_template.modality
shortname=shortname, fullname=fullname, blame=b)
new_session.event = self._find_by_id(event, facade.models.Event)
new_session.save()
if 'session_template' in optional_attributes:
the_session_template = self._find_by_id(optional_attributes['session_template'], facade.models.SessionTemplate)

if (the_session_template.session_template_user_role_requirements.all().count() != 0):
# We need to create a session_user_role_requirement for each of these and associate it with this session
for session_template_user_role_requirement in the_session_template.session_template_user_role_requirements.all():
Expand All @@ -160,7 +163,6 @@ def _create(self, auth_token, start, end, status, confirmed, default_price,

new_session.session_template = the_session_template
del optional_attributes['session_template']
new_session.name = new_session.name+new_session.mangle_id(new_session.id)
new_session.save()
if optional_attributes:
facade.subsystems.Setter(auth_token, self, new_session, optional_attributes)
Expand Down Expand Up @@ -336,7 +338,7 @@ def detailed_surr_view(self, auth_token, filters=None, fields=None):
"""
if filters is None:
filters = {}
ret = self.get_filtered(auth_token, filters, ['start', 'end', 'status', 'confirmed', 'event', 'name', 'room', 'title', 'url', 'description', 'session_user_role_requirements'])
ret = self.get_filtered(auth_token, filters, ['start', 'end', 'status', 'confirmed', 'event', 'fullname', 'room', 'shortname', 'title', 'url', 'description', 'session_user_role_requirements'])

ret = Utils.merge_queries(ret, facade.managers.RoomManager(), auth_token, ['name', 'venue_name', 'venue_address'], 'room')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_sessions_using_resource(self, auth_token, resource_id, activeOnly=False)
related_sessions = []
for req_id in related_requirements:
sessions = session_mgr.get_filtered(auth_token,
{ 'member' : {'session_resource_type_requirements' : [req_id] } }, ['name', 'description', 'start', 'end'])
{ 'member' : {'session_resource_type_requirements' : [req_id] } }, ['fullname', 'shortname', 'description', 'start', 'end'])
related_sessions += sessions

return related_sessions
Expand Down
2 changes: 1 addition & 1 deletion pr_services/exam_system/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ def test_all(self):
session1 = self.session_manager.create(self.admin_token,
self.right_now.isoformat(),
(self.right_now+self.one_day).isoformat(), 'active', True, 10000,
event1.id)
event1.id, 'short name 1', 'full name 1')
session1.evaluation = evaluation
session1.save()

Expand Down
2 changes: 1 addition & 1 deletion pr_services/gettersetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def get_paypal_url_from_session(self, result_object, field_name):
owner = result_object.event.owner
if result_object.default_price > 0 and owner.enable_paypal and owner.paypal_address != None and len(owner.paypal_address):
start = str(result_object.start)
date_and_code = '%s, %s' % (start, result_object.name)
date_and_code = '%s, %s' % (start, result_object.shortname)
if result_object.title != None:
title = result_object.title
elif result_object.event.title != None:
Expand Down
6 changes: 3 additions & 3 deletions pr_services/initial_setup/create_admin_user_group_and_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,11 @@ def setup(machine):
'c' : True,
'r' : ['session_user_role_requirements', 'session_resource_type_requirements', 'audience',
'confirmed', 'session_template', 'default_price',
'description', 'end', 'evaluation', 'modality', 'name',
'room', 'start', 'status', 'title', 'url', 'event',
'description', 'end', 'evaluation', 'fullname', 'modality',
'room', 'shortname', 'start', 'status', 'title', 'url', 'event',
'session_user_roles', 'paypal_url'],
'u' : [ 'session_user_role_requirements', 'session_resource_type_requirements', 'audience', 'confirmed', 'session_template', 'default_price', 'description',
'end', 'modality', 'name', 'room', 'start', 'status',
'end', 'fullname', 'modality', 'room', 'shortname', 'start', 'status',
'session_user_roles', 'title', 'url', 'event'],
'd' : True,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def setup(machine):
'Session' : {
'c' : True,
'r' : ['default_price', 'room', 'evaluation',
'start', 'end', 'session_template', 'name',
'start', 'end', 'session_template', 'shortname', 'fullname',
'audience', 'title', 'confirmed', 'status',
'url', 'modality'],
'u' : [ 'default_price', 'room', 'start', 'end', 'session_template', 'name', 'audience', 'title',
'u' : [ 'default_price', 'room', 'start', 'end', 'session_template', 'shortname', 'fullname', 'audience', 'title',
'confirmed', 'status', 'url', 'modality'],
'd' : True,
},
Expand Down
Loading

0 comments on commit cc78685

Please sign in to comment.