ouhft / COPE

Project Repository for Work Package 4 of the COPE Transplant Trial
https://cope.nds.ox.ac.uk
1 stars 0 forks source link

S/AE Form has ISE for missing person - due to case having no recipient #289

Closed marshalc closed 7 years ago

marshalc commented 7 years ago

From emails 2017-06-15@10:30-ish:

Internal Server Error: /en-gb/wp4/adverse-event/327/

AttributeError at /en-gb/wp4/adverse-event/327/
'NoneType' object has no attribute 'person'

Request Method: GET
Request URL: https://cope.nds.ox.ac.uk/en-gb/wp4/adverse-event/327/
Django Version: 1.10.6
Python Executable: /sites/.virtualenvs/py3_cope/bin/python3
Python Version: 3.5.2
Python Path: ['/sites/py3_cope/cope_repo', '/sites/.virtualenvs/py3_cope/bin', '/sites/py3_cope/cope_repo/${PYTHONPATH}', '/sites/py3_cope/cope_repo', '/sites/.virtualenvs/py3_cope/lib/python35.zip', '/sites/.virtualenvs/py3_cope/lib/python3.5', '/sites/.virtualenvs/py3_cope/lib/python3.5/plat-x86_64-linux-gnu', '/sites/.virtualenvs/py3_cope/lib/python3.5/lib-dynload', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages', '/sites/.virtualenvs/py3_cope/src/django-crispy-forms']
Server time: Thu, 15 Jun 2017 10:33:34 +0100
Installed Applications:
['dal',
'dal_select2',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.admin',
'django.contrib.admindocs',
'crispy_forms',
'reversion',
'reversion_compare',
'wp4.compare',
'wp4.locations',
'wp4.staff',
'wp4.perfusion_machine',
'wp4.health_economics',
'wp4.samples',
'wp4.adverse_event',
'wp4.followups',
'wp4.administration',
'wp4.theme',
'djangosecure',
'gunicorn']
Installed Middleware:
['djangosecure.middleware.SecurityMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'reversion.middleware.RevisionMiddleware',
'config.middleware.activate_timezone.TimezoneMiddleware']

Traceback:  

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
 42.             response = get_response(request)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
 249.             response = self._get_response(request)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
 187.                 response = self.process_exception_by_middleware(e, request)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
 185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/views/generic/base.py" in view
 68.             return self.dispatch(request, *args, **kwargs)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/braces/views/_access.py" in dispatch
 102.             request, *args, **kwargs)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/braces/views/_access.py" in dispatch
 201.             request, *args, **kwargs)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/views/generic/base.py" in dispatch
 88.         return handler(request, *args, **kwargs)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/views/generic/edit.py" in get
 236.         return super(BaseUpdateView, self).get(request, *args, **kwargs)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/views/generic/edit.py" in get
 174.         return self.render_to_response(self.get_context_data())

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/views/generic/edit.py" in get_context_data
 93.             kwargs['form'] = self.get_form()

File "/sites/py3_cope/cope_repo/wp4/adverse_event/views.py" in get_form
 107.         form = super(AjaxFormMixin, self).get_form(form_class)

File "/sites/.virtualenvs/py3_cope/lib/python3.5/site-packages/django/views/generic/edit.py" in get_form
 45.         return form_class(**self.get_form_kwargs())

File "/sites/py3_cope/cope_repo/wp4/adverse_event/forms.py" in __init__
 233.         super(AdminEventForm, self).__init__(*args, **kwargs)

File "/sites/py3_cope/cope_repo/wp4/adverse_event/forms.py" in __init__
 63.             self.fields['date_of_death'].initial = self.instance.organ.safe_recipient.person.date_of_death

Exception Type: AttributeError at /en-gb/wp4/adverse-event/327/
Exception Value: 'NoneType' object has no attribute 'person'
Request information:
USER: Ally Bradley

GET: No GET data

POST: No POST data

FILES: No FILES data

COOKIES:
dontShowCookieNotice = 'TRUE'
csrftoken = 'GZkLdMuMhgoNd4nlO8ICOFH6OvFQlmOoZblppKUUjE7ZMMklXi8RzJEvP5Dc8Hep'
sessionid = 'rkmgdv2aaiqponj9hfbdxwhu43arfjyk'
__utmz = '107475804.1493897057.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)'
__utma = '107475804.1678205995.1491993048.1493897057.1493897057.1'
_ga = 'GA1.4.1678205995.1491993048'

META:
CSRF_COOKIE = 'GZkLdMuMhgoNd4nlO8ICOFH6OvFQlmOoZblppKUUjE7ZMMklXi8RzJEvP5Dc8Hep'
HTTP_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
HTTP_ACCEPT_ENCODING = 'gzip, deflate, sdch, br'
HTTP_ACCEPT_LANGUAGE = 'en-US,en;q=0.8'
HTTP_CONNECTION = 'close'
HTTP_COOKIE = 'dontShowCookieNotice=TRUE; __utma=107475804.1678205995.1491993048.1493897057.1493897057.1; __utmz=107475804.1493897057.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.3.1678205995.1491993048; _ga=GA1.4.1678205995.1491993048; sessionid=rkmgdv2aaiqponj9hfbdxwhu43arfjyk; csrftoken=GZkLdMuMhgoNd4nlO8ICOFH6OvFQlmOoZblppKUUjE7ZMMklXi8RzJEvP5Dc8Hep'
HTTP_HOST = 'cope.nds.ox.ac.uk'
HTTP_REFERER = 'https://cope.nds.ox.ac.uk/en-gb/wp4/adverse-event/?ordering=asc&page=7&order_by=id'
HTTP_UPGRADE_INSECURE_REQUESTS = '1'
HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
HTTP_X_FORWARDED_FOR = '129.67.116.64'
HTTP_X_FORWARDED_PROTOCOL = 'https'
HTTP_X_REAL_IP = '129.67.116.64'
HTTP_X_SCHEME = 'https'
PATH_INFO = '/en-gb/wp4/adverse-event/327/'
QUERY_STRING = ''
RAW_URI = '/en-gb/wp4/adverse-event/327/'
REMOTE_ADDR = "b''"
REQUEST_METHOD = 'GET'
SCRIPT_NAME = ''
SERVER_NAME = 'cope.nds.ox.ac.uk'
SERVER_PORT = '80'
SERVER_PROTOCOL = 'HTTP/1.0'
SERVER_SOFTWARE = 'gunicorn/19.7.1'
gunicorn.socket = <socket.socket fd=13, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, laddr=/sites/py3_cope/var/run/wsgi.socket>
wsgi.errors = <gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7facb97c4ba8>
wsgi.file_wrapper = ''
wsgi.input = <gunicorn.http.body.Body object at 0x7facb8834f60>
wsgi.multiprocess = True
wsgi.multithread = False
wsgi.run_once = False
wsgi.url_scheme = 'http'
wsgi.version = 

Settings:
Using settings module config.settings.production
ABSOLUTE_URL_OVERRIDES = {}
ACCOUNT_AUTHENTICATION_METHOD = 'username'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ADD_REVERSION_ADMIN = True
ADMINS = [('Carl Marshall', 'carl.marshall@nds.ox.ac.uk')]
ALLOWED_HOSTS = ['cope.nds.ox.ac.uk', 'localhost', '127.0.0.1']
APPEND_SLASH = True
APPS_DIR = <Path:/sites/py3_cope/cope_repo/wp4>
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS = '********************'
AUTH_USER_MODEL = 'staff.Person'
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
BASE_DIR = '/sites/py3_cope/cope_repo'
CACHES = {'default': {'LOCATION': '', 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_KEY_PREFIX = '********************'
CACHE_MIDDLEWARE_SECONDS = 600
CRISPY_TEMPLATE_PACK = 'bootstrap3'
CSRF_COOKIE_AGE = 31449600
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_NAME = 'csrftoken'
CSRF_COOKIE_PATH = '/'
CSRF_COOKIE_SECURE = False
CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME = 'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS = []
DATABASES = {'default': {'ATOMIC_REQUESTS': False, 'USER': '', 'ENGINE': 'django.db.backends.sqlite3', 'OPTIONS': {}, 'TEST': {'CHARSET': None, 'NAME': None, 'COLLATION': None, 'MIRROR': None}, 'NAME': 'db.sqlite3', 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'TIME_ZONE': None, 'HOST': '', 'PORT': '', 'PASSWORD': '********************'}}
DATABASE_ROUTERS = []
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000
DATETIME_FORMAT = 'N j, Y, P'
DATETIME_INPUT_FORMATS = ['%d-%m-%Y %H:%M', '%Y-%m-%d %H:%M', '%d/%m/%Y %H:%M', '%Y/%m/%d %H:%M']
DATE_FORMAT = 'N j, Y'
DATE_INPUT_FORMATS = ['%d-%m-%Y', '%Y-%m-%d', '%d/%m/%Y', '%Y/%m/%d']
DEBUG = False
DEBUG_PROPAGATE_EXCEPTIONS = False
DECIMAL_SEPARATOR = '.'
DEFAULT_CHARSET = 'utf-8'
DEFAULT_CONTENT_TYPE = 'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL = 'COPE DB<no-reply@cope.nds.ox.ac.uk>'
DEFAULT_INDEX_TABLESPACE = ''
DEFAULT_TABLESPACE = ''
DISALLOWED_USER_AGENTS = []
DJANGO_APPS = ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.contrib.admin', 'django.contrib.admindocs']
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_FILE_PATH = '/sites/cope/tmp'
EMAIL_HOST = 'smtp.ox.ac.uk'
EMAIL_HOST_PASSWORD = '********************'
EMAIL_HOST_USER = ''
EMAIL_PORT = 25
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = '********************'
EMAIL_SUBJECT_PREFIX = '[Cope DB] '
EMAIL_TIMEOUT = None
EMAIL_USE_SSL = False
EMAIL_USE_TLS = False
FILE_CHARSET = 'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_HANDLERS = ['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_TEMP_DIR = None
FIRST_DAY_OF_WEEK = 0
FIXTURE_DIRS = ['/sites/py3_cope/cope_repo/wp4/fixtures', '/sites/py3_cope/cope_repo/config/fixtures']
FORCE_SCRIPT_NAME = None
FORMAT_MODULE_PATH = None
IGNORABLE_404_URLS = []
INSTALLED_APPS = ['dal', 'dal_select2', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.contrib.admin', 'django.contrib.admindocs', 'crispy_forms', 'reversion', 'reversion_compare', 'wp4.compare', 'wp4.locations', 'wp4.staff', 'wp4.perfusion_machine', 'wp4.health_economics', 'wp4.samples', 'wp4.adverse_event', 'wp4.followups', 'wp4.administration', 'wp4.theme', 'djangosecure', 'gunicorn']
INTERNAL_IPS = []
LANGUAGES = [('en-gb', <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7facbb529e80>), ('fr-be', <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7facbb530240>), ('nl-nl', <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7facbb530630>)]
LANGUAGES_BIDI = ['he', 'ar', 'fa', 'ur']
LANGUAGE_CODE = 'en-gb'
LANGUAGE_COOKIE_AGE = None
LANGUAGE_COOKIE_DOMAIN = None
LANGUAGE_COOKIE_NAME = 'django_language'
LANGUAGE_COOKIE_PATH = '/'
LOCALE_PATHS = ['/sites/py3_cope/cope_repo/locale']
LOCAL_APPS = ['wp4.compare', 'wp4.locations', 'wp4.staff', 'wp4.perfusion_machine', 'wp4.health_economics', 'wp4.samples', 'wp4.adverse_event', 'wp4.followups', 'wp4.administration', 'wp4.theme']
LOGGING = {'version': 1, 'disable_existing_loggers': False, 'formatters': {'verbose': {'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'}}, 'loggers': {'django.request': {'level': 'ERROR', 'propagate': True, 'handlers': ['mail_admins']}, 'loggers': {'django.security.DisallowedHost': {'level': 'ERROR', 'propagate': True, 'handlers': ['console', 'mail_admins']}}}, 'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}}, 'handlers': {'console': {'formatter': 'verbose', 'level': 'DEBUG', 'class': 'logging.StreamHandler'}, 'mail_admins': {'filters': ['require_debug_false'], 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler'}}}
LOGGING_CONFIG = 'logging.config.dictConfig'
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/accounts/login/'
LOGOUT_REDIRECT_URL = '/'
MANAGERS = [('Carl Marshall', 'carl.marshall@nds.ox.ac.uk')]
MEDIA_ROOT = '/sites/py3_cope/htdocs/media'
MEDIA_URL = '/media/'
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
MESSAGE_TAGS = {40: 'danger'}
MIDDLEWARE = None
MIDDLEWARE_CLASSES = ['djangosecure.middleware.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'reversion.middleware.RevisionMiddleware', 'config.middleware.activate_timezone.TimezoneMiddleware']
MIGRATION_MODULES = {}
MONTH_DAY_FORMAT = 'F j'
NUMBER_GROUPING = 0
PASSWORD_HASHERS = '********************'
PASSWORD_RESET_TIMEOUT_DAYS = '********************'
PREPEND_WWW = False
REDIRECT_FIELD_NAME = 'redirect_to'
ROOT_DIR = <Path:/sites/py3_cope/cope_repo>
ROOT_URLCONF = 'config.urls'
SECRET_KEY = '********************'
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_FRAME_DENY = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_SECONDS = 60
SECURE_PROXY_SSL_HEADER = 
SECURE_REDIRECT_EXEMPT = []
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = True
SECURITY_MIDDLEWARE = ['djangosecure.middleware.SecurityMiddleware']
SERVER_EMAIL = 'COPE DB<no-reply@cope.nds.ox.ac.uk>'
SESSION_CACHE_ALIAS = 'default'
SESSION_COOKIE_AGE = 1209600
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_NAME = 'sessionid'
SESSION_COOKIE_PATH = '/'
SESSION_COOKIE_SECURE = False
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_FILE_PATH = None
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE = 'config.settings.production'
SHORT_DATETIME_FORMAT = 'm/d/Y P'
SHORT_DATE_FORMAT = 'm/d/Y'
SIGNING_BACKEND = 'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS = []
SITE_ID = 1
STATICFILES_DIRS = ['/sites/py3_cope/cope_repo/wp4/static', '/sites/py3_cope/cope_repo/docs/static']
STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = '/sites/py3_cope/htdocs/'
STATIC_URL = '/static/'
TEMPLATES = [{'DIRS': ['/sites/py3_cope/cope_repo/wp4/templates'], 'OPTIONS': {'loaders': [('django.template.loaders.cached.Loader', ['django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader'])], 'debug': False, 'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.i18n', 'django.template.context_processors.tz', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.contrib.messages.context_processors.messages']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates'}]
TEST_NON_SERIALIZED_APPS = []
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
THIRD_PARTY_APPS = ['crispy_forms', 'reversion', 'reversion_compare']
THIRD_PARTY_PRE_DJANGO_APPS = ['dal', 'dal_select2']
THOUSAND_SEPARATOR = ','
TIME_FORMAT = 'P'
TIME_INPUT_FORMATS = ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
TIME_ZONE = 'UTC'
USE_ETAGS = False
USE_I18N = True
USE_L10N = True
USE_THOUSAND_SEPARATOR = False
USE_TZ = True
USE_X_FORWARDED_HOST = False
USE_X_FORWARDED_PORT = False
WSGI_APPLICATION = 'config.wsgi.application'
X_FRAME_OPTIONS = 'SAMEORIGIN'
YEAR_MONTH_FORMAT = 'F Y'
marshalc commented 7 years ago

Problem is that the test for a missing organ recipient wasn't being triggered in two instances (events 323 and 327), so an extra test for a valid recipient has been added.