Commit 445cd24d authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: fix user account assignment creation from SubscriptionRequest

parent 2727476e
......@@ -13,22 +13,22 @@ if person.getLanguage() in [None, ""]:
person.setLanguage(context.getLanguage())
# Should come from subscription condition probably or preference
role_list = ['member', 'subscriber']
function_list = ['customer']
open_assignment_list = person.searchFolder(portal_type="Assignment",
validation_state="open")
current_assignment_list = {}
for assignment in open_assignment_list:
role = assignment.getRole()
if role in current_assignment_list:
current_assignment_list[role].append(assignment)
function = assignment.getFunction()
if function in current_assignment_list:
current_assignment_list[function].append(assignment)
else:
current_assignment_list[role] = [assignment]
current_assignment_list[function] = [assignment]
for role in role_list:
if role in current_assignment_list:
for function in function_list:
if function in current_assignment_list:
# Update assignment (Reset stop/start dates)
for assignment in current_assignment_list[role]:
for assignment in current_assignment_list[function]:
if assignment.getStartDate() is None or \
assignment.getStopDate() is None:
assignment.update()
......@@ -40,8 +40,10 @@ for role in role_list:
# Create assignment
assignment = person.newContent(
portal_type='Assignment',
title = '%s Assignment' % (role.capitalize()),
role = role)
title = '%s Assignment' % (function.capitalize()),
function = function,
destination_project=context.getSourceProject()
)
assignment.open(comment="Created by Subscription Request")
......@@ -68,16 +70,6 @@ try:
except UnsupportedWorkflowMethod:
pass
person.edit(default_career_role_list=role_list)
default_career = getattr(person,'default_career',None)
# Try to validate the default career
try:
default_career.start(comment="Started by Subscription Request")
default_career.setStartDate(DateTime())
except UnsupportedWorkflowMethod:
pass
context.activate(activity='SQLQueue').SubscriptionRequest_sendAcceptedNotification(reference, password)
context.order()
......@@ -989,7 +989,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self.assertEqual(len(login_list), 1)
self.assertEqual(login_list[0].getReference(), person.getDefaultEmailText())
self.assertSameSet(person.getRoleList(), ["member", "subscriber"])
def checkEmailNotification(self, subscription_request,
notification_message="subscription_request-confirmation-with-password"):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment