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

ISE: AttributeError at /nl-nl/wp4/adverse-event/328/ 'NoneType' object has no attribute 'person' #274

Closed marshalc closed 7 years ago

marshalc commented 7 years ago

Series of emails from this morning's log:

Internal Server Error: /nl-nl/wp4/adverse-event/328/

AttributeError at /nl-nl/wp4/adverse-event/328/
'NoneType' object has no attribute 'person'

Request Method: GET
Request URL: https://cope.nds.ox.ac.uk/nl-nl/wp4/adverse-event/328/
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: vrij, 31 Mrt 2017 10:08:51 +0200
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
 93.         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 /nl-nl/wp4/adverse-event/328/
Exception Value: 'NoneType' object has no attribute 'person'
Request information:
USER: Sarah Mertens

GET: No GET data

POST: No POST data

FILES: No FILES data

COOKIES:
_ga = 'GA1.4.2053793849.1488273583'
csrftoken = 'NfCBKBv8rnfqRwh3L2aj1dVYMR4w4ahrHXgO4khFobwkj0S7J4WCJhtysxgSDUGJ'
sessionid = 'veln9ymlxekh1lv1rt721jc3prhb86a0'

META:
CSRF_COOKIE = 'NfCBKBv8rnfqRwh3L2aj1dVYMR4w4ahrHXgO4khFobwkj0S7J4WCJhtysxgSDUGJ'
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 = 'nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4'
HTTP_CONNECTION = 'close'
HTTP_COOKIE = '_ga=GA1.3.2053793849.1488273583; _ga=GA1.4.2053793849.1488273583; sessionid=veln9ymlxekh1lv1rt721jc3prhb86a0; csrftoken=NfCBKBv8rnfqRwh3L2aj1dVYMR4w4ahrHXgO4khFobwkj0S7J4WCJhtysxgSDUGJ'
HTTP_HOST = 'cope.nds.ox.ac.uk'
HTTP_UPGRADE_INSECURE_REQUESTS = '1'
HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'
HTTP_X_FORWARDED_FOR = '134.58.179.6'
HTTP_X_FORWARDED_PROTOCOL = 'https'
HTTP_X_REAL_IP = '134.58.179.6'
HTTP_X_SCHEME = 'https'
PATH_INFO = '/nl-nl/wp4/adverse-event/328/'
QUERY_STRING = ''
RAW_URI = '/nl-nl/wp4/adverse-event/328/'
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.0'
gunicorn.socket = <socket.socket fd=12, 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 0x7f0eb2dd20b8>
wsgi.file_wrapper = ''
wsgi.input = <gunicorn.http.body.Body object at 0x7f0eb2dd2828>
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': {'OPTIONS': {}, 'PASSWORD': '********************', 'USER': '', 'PORT': '', 'CONN_MAX_AGE': 0, 'NAME': 'db.sqlite3', 'ATOMIC_REQUESTS': False, 'TEST': {'NAME': None, 'COLLATION': None, 'MIRROR': None, 'CHARSET': None}, 'TIME_ZONE': None, 'AUTOCOMMIT': True, 'HOST': '', 'ENGINE': 'django.db.backends.sqlite3'}}
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 <noreply@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 = '/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 0x7f0eb6d06f60>), ('fr-be', <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7f0eb6d10320>), ('nl-nl', <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7f0eb6d10710>)]
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 = {'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}}, 'version': 1, 'handlers': {'console': {'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose'}, 'mail_admins': {'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', 'filters': ['require_debug_false']}}, 'formatters': {'verbose': {'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'}}, 'loggers': {'loggers': {'django.security.DisallowedHost': {'level': 'ERROR', 'handlers': ['console', 'mail_admins'], 'propagate': True}}, 'django.request': {'level': 'ERROR', 'handlers': ['mail_admins'], 'propagate': True}}, 'disable_existing_loggers': False}
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 <noreply@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 = [{'OPTIONS': {'debug': False, 'loaders': [('django.template.loaders.cached.Loader', ['django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader'])], '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', 'DIRS': ['/sites/py3_cope/cope_repo/wp4/templates']}]
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'

Occurs 4 times, all from @mertenssarah .

Also same error for ID 327 (4 times), 323 (4 times).

I suspect this is adverse events being entered for Organs without recipients. So need to try and trap this more neatly, and ensure they can't answer questions about someone dying that doesn't yet exist.

marshalc commented 7 years ago

Duplicated (and fixed) this with #289