kbaskett248 / fair_scoring_site

0 stars 0 forks source link

Fix the 500 error that judges get when clicking a link for a judging instance that no longer exists #21

Closed kbaskett248 closed 6 years ago

kbaskett248 commented 7 years ago

If judging instances are modified while a judge is viewing their project list, some of the links may be invalidated. The links are based on the pk of the judging instance. So deleting a judging instance invalidates those links.

Consider one or more of the fixes below:

  1. Redirect the judge back to their list in the case of an error.
  2. Use a number other than the primary key. Consider a hash of the project number, judge pk, and rubric pk, since that combination should be unique.

Internal Server Error: /projects/judgingresponse/97

DoesNotExist at /projects/judgingresponse/97 JudgingInstance matching query does not exist.

Request Method: GET Request URL: http://rmsstschoolfair.pythonanywhere.com/projects/judgingresponse/97 Django Version: 1.10.4 Python Executable: /usr/local/bin/uwsgi Python Version: 3.5.2 Python Path: ['/var/www', '.', '', '/var/www', '/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5', '/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/plat-x86_64-linux-gnu', '/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/lib-dynload', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages', '/home/rmsstschoolfair/fair_scoring_site'] Server time: Tue, 18 Apr 2017 15:33:29 -0400 Installed Applications: ['awards.apps.AwardsConfig', 'judges.apps.JudgesConfig', 'fair_categories.apps.FairCategoriesConfig', 'fair_projects.apps.FairProjectsConfig', 'rubrics.apps.RubricsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap3', 'constance', 'constance.backends.database', 'import_export', 'widget_tweaks'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response

  1. response = self._get_response(request)

File "/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages/django/views/generic/base.py" in view

  1. return self.dispatch(request, *args, **kwargs)

File "/home/rmsstschoolfair/fair_scoring_site/fair_projects/views.py" in dispatch

  1. required_user = self.get_required_user(*args, **kwargs)

File "/home/rmsstschoolfair/fair_scoring_site/fair_projects/views.py" in get_required_user

  1. self.judging_instance = self.queryset.get(pk=kwargs[self.pk_url_kwarg])

File "/home/rmsstschoolfair/.virtualenvs/fair_scoring_site_venv/lib/python3.5/site-packages/django/db/models/query.py" in get

  1. self.model._meta.object_name

Exception Type: DoesNotExist at /projects/judgingresponse/97 Exception Value: JudgingInstance matching query does not exist. Request information: USER: 9mmurphy1

GET: No GET data

POST: No POST data

FILES: No FILES data

COOKIES: sessionid = 's1nzm10la32h9h83ohxpujlewn85lqed' csrftoken = 'nEYKsaqalwN1lgCODLa0a7tSRVQT16gkdQG16GrNuzUNVnKvdnAZNbvHFAexcnr4'

META: CONTENT_LENGTH = '' CONTENT_TYPE = '' CSRF_COOKIE = 'nEYKsaqalwN1lgCODLa0a7tSRVQT16gkdQG16GrNuzUNVnKvdnAZNbvHFAexcnr4' DOCUMENT_ROOT = '/usr/local/openresty/nginx/html' HTTP_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8' HTTP_ACCEPT_ENCODING = 'gzip, deflate' HTTP_ACCEPT_LANGUAGE = 'en-us' HTTP_CONNECTION = 'close' HTTP_COOKIE = 'csrftoken=nEYKsaqalwN1lgCODLa0a7tSRVQT16gkdQG16GrNuzUNVnKvdnAZNbvHFAexcnr4; sessionid=s1nzm10la32h9h83ohxpujlewn85lqed' HTTP_DNT = '1' HTTP_HOST = 'rmsstschoolfair.pythonanywhere.com' HTTP_REFERER = 'http://rmsstschoolfair.pythonanywhere.com/projects/judge/9mmurphy1' HTTP_UPGRADE_INSECURE_REQUESTS = '1' HTTP_USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1' HTTP_X_FORWARDED_FOR = '174.218.14.124' HTTP_X_REAL_IP = '174.218.14.124' PATH_INFO = '/projects/judgingresponse/97' QUERY_STRING = '' REMOTE_ADDR = '10.0.0.95' REMOTE_PORT = '44300' REQUEST_METHOD = 'GET' REQUEST_URI = '/projects/judgingresponse/97' SCRIPT_NAME = '' SERVER_NAME = 'rmsstschoolfair.pythonanywhere.com' SERVER_PORT = '80' SERVER_PROTOCOL = 'HTTP/1.1' uwsgi.node = b'giles-liveweb7' uwsgi.version = b'2.0.5.1' wsgi.errors = <uwsgi_file__bin_user_wsgi_wrapper.ErrorLogFile object at 0x7f31266c4128> wsgi.file_wrapper = '' wsgi.input = <uwsgi._Input object at 0x7f31253bc1b0> wsgi.multiprocess = False wsgi.multithread = False wsgi.run_once = False wsgi.url_scheme = 'http' wsgi.version =

Settings: Using settings module fair_scoring_site.settings ABSOLUTE_URL_OVERRIDES = {} ADMINS = [('Kenny Baskett', 'kbaskett248@gmail.com')] ALLOWED_HOSTS = ['rmsstschoolfair.pythonanywhere.com', 'www.rmsstschoolfair.pythonanywhere.com'] APPEND_SLASH = True AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend'] AUTH_PASSWORD_VALIDATORS = '****' AUTH_USER_MODEL = 'auth.User' BASE_DIR = '/home/rmsstschoolfair/fair_scoring_site' BOOTSTRAP3 = {'include_jquery': True} CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} CACHE_MIDDLEWARE_ALIAS = 'default' CACHE_MIDDLEWARE_KEY_PREFIX = '****' CACHE_MIDDLEWARE_SECONDS = 600 CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' CONSTANCE_CONFIG = {'RUBRIC_NAME': ('Judging Form', 'The name of the rubric judges will use to assess projects'), 'FAIR_ABBR': ('SF', 'Abbreviation for the name of the science fair'), 'FAIR_NAME': ('Science Fair', 'The name of the science fair'), 'JUDGING_ACTIVE': (False, 'Check this box during judging'), 'PROJECTS_PER_JUDGE': (5, 'The minimum number of projects that should be assigned to each judge'), 'JUDGES_PER_PROJECT': (3, 'The number of judges that should be assigned to judge each project')} CONSTANCE_CONFIG_FIELDSETS = {'Fair Name': ('FAIR_NAME', 'FAIR_ABBR'), 'Judging': ('JUDGES_PER_PROJECT', 'PROJECTS_PER_JUDGE', 'JUDGING_ACTIVE', 'RUBRIC_NAME')} CONSTANCE_DATABASE_PREFIX = 'constance:fair_scoring_site:' 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': {'ENGINE': 'django.db.backends.mysql', 'AUTOCOMMIT': True, 'TIME_ZONE': None, 'ATOMIC_REQUESTS': False, 'CONN_MAX_AGE': 0, 'TEST': {'NAME': None, 'COLLATION': None, 'MIRROR': None, 'CHARSET': None}, 'NAME': 'rmsstschoolfair$freshmenposter', 'HOST': 'rmsstschoolfair.mysql.pythonanywhere-services.com', 'PORT': '3306', 'PASSWORD': '****', 'OPTIONS': {}, 'USER': 'rmsstschoolfair'}} DATABASE_ROUTERS = [] DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000 DATETIME_FORMAT = 'N j, Y, P' DATETIME_INPUT_FORMATS = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M', '%m/%d/%y'] DATE_FORMAT = 'N j, Y' DATE_INPUT_FORMATS = ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'] 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 = 'webmaster@localhost' DEFAULT_INDEX_TABLESPACE = '' DEFAULT_TABLESPACE = '' DISALLOWED_USER_AGENTS = [] EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_PASSWORD = '****' EMAIL_HOST_USER = 'rmsstschoolfair@gmail.com' EMAIL_PORT = 587 EMAIL_SSL_CERTFILE = None EMAIL_SSL_KEYFILE = '****' EMAIL_SUBJECT_PREFIX = '[Django] ' EMAIL_TIMEOUT = None EMAIL_USE_SSL = False EMAIL_USE_TLS = True 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 = [] FORCE_SCRIPT_NAME = None FORMAT_MODULE_PATH = None IGNORABLE_404_URLS = [] INSTALLED_APPS = ['awards.apps.AwardsConfig', 'judges.apps.JudgesConfig', 'fair_categories.apps.FairCategoriesConfig', 'fair_projects.apps.FairProjectsConfig', 'rubrics.apps.RubricsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap3', 'constance', 'constance.backends.database', 'import_export', 'widget_tweaks'] INTERNAL_IPS = [] LANGUAGES = [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')] LANGUAGES_BIDI = ['he', 'ar', 'fa', 'ur'] LANGUAGE_CODE = 'en-us' LANGUAGE_COOKIE_AGE = None LANGUAGE_COOKIE_DOMAIN = None LANGUAGE_COOKIE_NAME = 'django_language' LANGUAGE_COOKIE_PATH = '/' LOCALE_PATHS = [] LOGGING = {} LOGGING_CONFIG = 'logging.config.dictConfig' LOGIN_REDIRECT_URL = '/accounts/profile/' LOGIN_URL = '/accounts/login/' LOGOUT_REDIRECT_URL = None MANAGERS = [] MEDIA_ROOT = '' MEDIA_URL = '' MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage' MIDDLEWARE = None MIDDLEWARE_CLASSES = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] MIGRATION_MODULES = {} MONTH_DAY_FORMAT = 'F j' NUMBER_GROUPING = 0 PASSWORD_HASHERS = '****' PASSWORD_RESET_TIMEOUT_DAYS = '****' PREPEND_WWW = False ROOT_URLCONF = 'fair_scoring_site.urls' SECRET_KEY = '****' SECURE_BROWSER_XSS_FILTER = True SECURE_CONTENT_TYPE_NOSNIFF = True SECURE_HSTS_INCLUDE_SUBDOMAINS = False SECURE_HSTS_SECONDS = 0 SECURE_PROXY_SSL_HEADER = None SECURE_REDIRECT_EXEMPT = [] SECURE_SSL_HOST = None SECURE_SSL_REDIRECT = False SERVER_EMAIL = 'root@localhost' 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 = 'fair_scoring_site.settings' SHORT_DATETIME_FORMAT = 'm/d/Y P' SHORT_DATE_FORMAT = 'm/d/Y' SIGNING_BACKEND = 'django.core.signing.TimestampSigner' SILENCED_SYSTEM_CHECKS = [] STATICFILES_DIRS = [] STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder'] STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_ROOT = '/home/rmsstschoolfair/fair_scoring_site/static' STATIC_URL = '/static/' TEMPLATES = [{'OPTIONS': {'context_processors': ['constance.context_processors.config', 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['/home/rmsstschoolfair/fair_scoring_site/templates'], 'APP_DIRS': True}] TEST_NON_SERIALIZED_APPS = [] TEST_RUNNER = 'django.test.runner.DiscoverRunner' THOUSAND_SEPARATOR = ',' TIME_FORMAT = 'P' TIME_INPUT_FORMATS = ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M'] TIME_ZONE = 'America/New_York' 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 = 'fair_scoring_site.wsgi.application' X_FRAME_OPTIONS = 'DENY' YEAR_MONTH_FORMAT = 'F Y'

kbaskett248 commented 6 years ago

Issue resolved by956d146. The judge is redirected back to their list of projects.