Commit 9270eedb authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: fix user account assignment creation from SubscriptionRequest

parent 252b37d2
...@@ -13,22 +13,22 @@ if person.getLanguage() in [None, ""]: ...@@ -13,22 +13,22 @@ if person.getLanguage() in [None, ""]:
person.setLanguage(context.getLanguage()) person.setLanguage(context.getLanguage())
# Should come from subscription condition probably or preference # Should come from subscription condition probably or preference
role_list = ['member', 'subscriber'] function_list = ['customer']
open_assignment_list = person.searchFolder(portal_type="Assignment", open_assignment_list = person.searchFolder(portal_type="Assignment",
validation_state="open") validation_state="open")
current_assignment_list = {} current_assignment_list = {}
for assignment in open_assignment_list: for assignment in open_assignment_list:
role = assignment.getRole() function = assignment.getFunction()
if role in current_assignment_list: if function in current_assignment_list:
current_assignment_list[role].append(assignment) current_assignment_list[function].append(assignment)
else: else:
current_assignment_list[role] = [assignment] current_assignment_list[function] = [assignment]
for role in role_list: for function in function_list:
if role in current_assignment_list: if function in current_assignment_list:
# Update assignment (Reset stop/start dates) # 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 \ if assignment.getStartDate() is None or \
assignment.getStopDate() is None: assignment.getStopDate() is None:
assignment.update() assignment.update()
...@@ -40,8 +40,10 @@ for role in role_list: ...@@ -40,8 +40,10 @@ for role in role_list:
# Create assignment # Create assignment
assignment = person.newContent( assignment = person.newContent(
portal_type='Assignment', portal_type='Assignment',
title = '%s Assignment' % (role.capitalize()), title = '%s Assignment' % (function.capitalize()),
role = role) function = function,
destination_project=context.getSourceProject()
)
assignment.open(comment="Created by Subscription Request") assignment.open(comment="Created by Subscription Request")
...@@ -68,16 +70,6 @@ try: ...@@ -68,16 +70,6 @@ try:
except UnsupportedWorkflowMethod: except UnsupportedWorkflowMethod:
pass 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.activate(activity='SQLQueue').SubscriptionRequest_sendAcceptedNotification(reference, password)
context.order() context.order()
...@@ -981,7 +981,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -981,7 +981,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self.assertEqual(len(login_list), 1) self.assertEqual(len(login_list), 1)
self.assertEqual(login_list[0].getReference(), person.getDefaultEmailText()) self.assertEqual(login_list[0].getReference(), person.getDefaultEmailText())
self.assertSameSet(person.getRoleList(), ["member", "subscriber"])
def checkEmailNotification(self, subscription_request, def checkEmailNotification(self, subscription_request,
notification_message="subscription_request-confirmation-with-password"): 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