{"action":"opened","issue":{"url":"https://api.github.com/repos/Karaage-Cluster/karaage/issues/284","repository_url":"https://api.github.com/repos/Karaage-Cluster/karaage","labels_url":"https://api.github.com/repos/Karaage-Cluster/karaage/issues/284/labels{/name}","comments_url":"https://api.github.com/repos/Karaage-Cluster/karaage/issues/284/comments","events_url":"https://api.github.com/repos/Karaage-Cluster/karaage/issues/284/events","html_url":"https://github.com/Karaage-Cluster/karaage/issues/284","id":173678564,"number":284,"title":"Adding new Institutes causes 500 & stacktrace","user":{"login":"DanielTosello","id":7378931,"avatar_url":"https://avatars.githubusercontent.com/u/7378931?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielTosello","html_url":"https://github.com/DanielTosello","followers_url":"https://api.github.com/users/DanielTosello/followers","following_url":"https://api.github.com/users/DanielTosello/following{/other_user}","gists_url":"https://api.github.com/users/DanielTosello/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielTosello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielTosello/subscriptions","organizations_url":"https://api.github.com/users/DanielTosello/orgs","repos_url":"https://api.github.com/users/DanielTosello/repos","events_url":"https://api.github.com/users/DanielTosello/events{/privacy}","received_events_url":"https://api.github.com/users/DanielTosello/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-29T01:01:43Z","updated_at":"2016-08-29T01:01:43Z","closed_at":null,"body":"Attempting to add a new institute *with a delegate* via the admin institutes GUI causes a 500 in browser and stacktrace in django.log:\r\n```\r\nERROR 2016-08-29 10:33:12,139 base 31862 140135060440832 Internal Server Error: /karaage/institutes/add/\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python2.7/dist-packages/django/core/handlers/base.py\", line 132, in get_response\r\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/django/utils/decorators.py\", line 145, in inner\r\n    return func(*args, **kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py\", line 22, in _wrapped_view\r\n    return view_func(request, *args, **kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/karaage/institutes/views.py\", line 159, in add_edit_institute\r\n    delegate_formset.save()\r\n  File \"/usr/lib/python2.7/dist-packages/django/forms/models.py\", line 636, in save\r\n    return self.save_existing_objects(commit) + self.save_new_objects(commit)\r\n  File \"/usr/lib/python2.7/dist-packages/django/forms/models.py\", line 767, in save_new_objects\r\n    self.new_objects.append(self.save_new(form, commit=commit))\r\n  File \"/usr/lib/python2.7/dist-packages/django/forms/models.py\", line 900, in save_new\r\n    obj.save()\r\n  File \"/usr/lib/python2.7/dist-packages/model_utils/tracker.py\", line 134, in save\r\n    ret = original_save(**kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/karaage/institutes/models.py\", line 217, in save\r\n    super(InstituteDelegate, self).save(*args, **kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/django/db/models/base.py\", line 685, in save\r\n    \"unsaved related object '%s'.\" % field.name\r\nValueError: save() prohibited to prevent data loss due to unsaved related object 'institute'.\r\n```\r\n\r\nAdding a new institute without a delegate returns a form error as expected, but creates the institute record anyway. I am currently using this as a workaround & adding delegates after institute creation. I assume this means that there is a model relationship issue.\r\n\r\nNote i manually created the group entry after finding this error but before finding the workaround. The institute correctly associated with the group i created for it. It is possible that the model issue is also affected by the existence of the associated group but providing it manually isn't a sufficient fix."}}
{"actor":{"display_login":"DanielTosello"}}