Skip to content
Snippets Groups Projects
Commit 7b71d7f6 authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Correcting spelling of @example.com.

parent 7ab7723b
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,19 @@ class Command(BaseCommand):
node = self.data[id]
form_data = {}
try:
determination = Determination.objects.get(drupal_id=node['nid'])
except Determination.DoesNotExist:
determination = Determination(drupal_id=node['nid'])
# TODO timezone?
determination.created_at = datetime.fromtimestamp(int(node['created']), timezone.utc)
determination.updated_at = datetime.fromtimestamp(int(node['changed']), timezone.utc)
determination.author = self.get_user(node['uid'])
determination.submission = self.get_submission(node)
determination.outcome = self.get_determination(node)
determination.message = self.get_field_value('field_cnsr_determination_message', node)
for field in node:
if field in self.STREAMFIELD_MAP:
try:
......@@ -63,24 +76,17 @@ class Command(BaseCommand):
except TypeError:
pass
determination.data = form_data
import pprint
pprint.pprint(f"{node['nid']}: {determination}")
pprint.pprint(determination.data)
try:
determination = Determination.objects.create(
created_at=datetime.fromtimestamp(int(node['created']), timezone.utc),
updated_at=datetime.fromtimestamp(int(node['changed']), timezone.utc),
author=self.get_user(node['uid']),
submission=self.get_submission(node['field_submission_proposal']['target_id']),
outcome=self.get_determination(node),
message=self.get_field_value('field_cnsr_determination_message', node),
data=form_data,
)
try:
determination.save()
self.stdout.write(f"Processed \"{node['title']}\" ({node['nid']})")
except IntegrityError:
self.stdout.write(f"Skipped \"{node['title']}\" ({node['nid']}) due to IntegrityError")
pass
except ValueError:
self.stdout.write(f"Skipped \"{node['title']}\" ({node['nid']}) due to ValueError")
determination.save()
self.stdout.write(f"Processed \"{node['title']}\" ({node['nid']})")
except IntegrityError:
self.stdout.write(f"Skipped \"{node['title']}\" ({node['nid']}) due to IntegrityError")
pass
def get_field_value(self, field, node):
......@@ -144,8 +150,9 @@ class Command(BaseCommand):
except User.DoesNotExist:
return None
def get_submission(self, nid):
def get_submission(self, node):
try:
nid = node['field_submission_concept_note']['target_id']
return ApplicationSubmission.objects.get(drupal_id=nid)
except ApplicationSubmission.DoesNotExist:
return 'None'
......
......@@ -128,7 +128,7 @@ class Command(BaseCommand):
created_at=datetime.fromtimestamp(int(node['created']), timezone.utc),
updated_at=datetime.fromtimestamp(int(node['changed']), timezone.utc),
author=self.get_user(node['uid']),
submission=self.get_submission(node['field_submission_concept_note']['target_id']),
submission=self.get_submission(node),
outcome=self.get_determination(node),
message=self.get_field_value('field_psr_determination_message', node),
data=form_data,
......@@ -204,8 +204,9 @@ class Command(BaseCommand):
except User.DoesNotExist:
return None
def get_submission(self, nid):
def get_submission(self, node):
try:
nid = node['field_submission_proposal']['target_id']
return ApplicationSubmission.objects.get(drupal_id=nid)
except ApplicationSubmission.DoesNotExist:
return 'None'
......
......@@ -107,7 +107,7 @@ class MigrateCommand(BaseCommand):
if hasattr(submission.user, 'email'):
form_data["email"] = submission.user.email
else:
form_data["email"] = f"user+{node['uid']}@exeample.com"
form_data["email"] = f"user+{node['uid']}@example.com"
if "address" not in form_data or not form_data["address"]:
form_data["address"] = json.dumps({"country": "GB", "thoroughfare": "This is not a real address!", "premise": "", "localityname": "London", "administrativearea": "", "postalcode": "123"})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment