Skip to content

Commit

Permalink
Merge pull request #3142 from SEED-platform/3140-bug/redirect-home-on…
Browse files Browse the repository at this point in the history
…-404

redirect home on 404
  • Loading branch information
perryr16 committed Mar 3, 2022
2 parents 3c0a059 + 217b43c commit 3654e12
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 60 deletions.
Binary file modified locale/en_US/LC_MESSAGES/django.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions locale/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,12 @@ msgstr "HOW TO MANUALLY MATCH YOUR PROPERTIES AND TAX LOTS:"
msgid "HOW_SYSTEM_AUTO_MATCHES_EXPLANATION"
msgstr "Your source data file(s) are presented in the table on the left. All properties/tax lots where a possible data match exists are presented in a table on the right. The system attempts to auto-match records using shared unique IDs like: PM Property ID, Jurisdiction Tax Lot ID, and Custom IDs as well as Address information. Where the system believes a match exists between a record in your source file and an existing record it will auto-check the 'match' <i class=\"fa fa-check-square-o\"></i> checkbox &mdash; effectively making a match between these records."

msgid "HTTP Error! Status Code: 404. The requested URL was not found."
msgstr "HTTP Error! Status Code: 404. The requested URL was not found."

msgid "HTTP Error! Status Code: 500. Internal Server Error."
msgstr "HTTP Error! Status Code: 500. Internal Server Error."

#: seed/templates/seed/account_create_email.html:2
msgid "Hello %(first_name)s, "
msgstr "Hello %(first_name)s, "
Expand Down
Binary file modified locale/fr_CA/LC_MESSAGES/django.mo
Binary file not shown.
6 changes: 6 additions & 0 deletions locale/fr_CA/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,12 @@ msgstr "COMMENT APPORTER MANUELLEMENT VOS PROPRIETES ET LOTS D'IMPÔT:"
msgid "HOW_SYSTEM_AUTO_MATCHES_EXPLANATION"
msgstr "Votre fichier de données source est présenté dans le tableau de gauche. Toutes les propriétés/lots d'impôt où une correspondance de données possible existe sont présentées dans un tableau sur la droite. Le système tente de faire correspondre automatiquement les enregistrements à l'aide d'ID uniques partagés tels que: ID de Propriété PM, ID de Lot d'Impôt de Juridiction et les ID personnalisés, ainsi que des informations d'adresse. Lorsque le système croit qu'une correspondance existe entre un enregistrement de votre fichier source et un enregistrement existant, il vérifie automatiquement la 'correspondance' <i class=\"fa fa-check-square-o\"></i> case à cocher &mdash; faire efficacement une correspondance entre ces enregistrements."

msgid "HTTP Error! Status Code: 404. The requested URL was not found."
msgstr "Erreur HTTP! Code d'état : 404. L'URL demandée est introuvable."

msgid "HTTP Error! Status Code: 500. Internal Server Error."
msgstr "Erreur HTTP! Code d'état : 500. Erreur interne du serveur."

#: seed/templates/seed/account_create_email.html:2
msgid "Hello %(first_name)s, "
msgstr "Bonjour% (first_name) s,"
Expand Down
9 changes: 9 additions & 0 deletions seed/static/seed/js/controllers/menu_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ angular.module('BE.seed.controller.menu', [])
});
}
};

if ($location.search().http_error) {
$scope.http_error = $location.search().http_error
}

$scope.closeAlert = function () {
$scope.http_error = false
}

init();
init_menu();
}]);
7 changes: 2 additions & 5 deletions seed/static/seed/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@
"GEOCODING_NOW": "Geocoding now...",
"GJ\/\/year": "GJ\/\/year",
"GREENBUTTON_CONTENTS_TITLE": "Confirm GreenButton File Contents",
"SENSOR_CONTENTS_TITLE": "Confirm File Contents",
"Geocode": "Geocode",
"Geocode Selected": "Geocode Selected",
"Geocoding Confidence": "Geocoding Confidence",
Expand All @@ -363,6 +362,8 @@
"HOW THE SYSTEM AUTO-MATCHES YOUR PROPERTIES AND TAX LOTS:": "HOW THE SYSTEM AUTO-MATCHES YOUR PROPERTIES AND TAX LOTS:",
"HOW TO MANUALLY MATCH YOUR PROPERTIES AND TAX LOTS:": "HOW TO MANUALLY MATCH YOUR PROPERTIES AND TAX LOTS:",
"HOW_SYSTEM_AUTO_MATCHES_EXPLANATION": "Your source data file(s) are presented in the table on the left. All properties\/tax lots where a possible data match exists are presented in a table on the right. The system attempts to auto-match records using shared unique IDs like: PM Property ID, Jurisdiction Tax Lot ID, and Custom IDs as well as Address information. Where the system believes a match exists between a record in your source file and an existing record it will auto-check the 'match' <i class=\"fa fa-check-square-o\"><\/i> checkbox &mdash; effectively making a match between these records.",
"HTTP Error! Status Code: 404. The requested URL was not found.": "HTTP Error! Status Code: 404. The requested URL was not found.",
"HTTP Error! Status Code: 500. Internal Server Error.": "HTTP Error! Status Code: 500. Internal Server Error.",
"Hello %(first_name)s, ": "Hello %(first_name)s, ",
"Highlights of SEED Platform™": "Highlights of SEED Platform™",
"Home Energy Score ID": "Home Energy Score ID",
Expand All @@ -376,7 +377,6 @@
"INVALID_EXTENSION_ALERT": "<strong>Sorry!<\/strong> SEED doesn't currently support that file format. Only <strong>.csv<\/strong>, <strong>.xls<\/strong>, <strong>.xlsx<\/strong>, and <strong>.xml<\/strong> files are supported.",
"INVALID_GEOJSON_EXTENSION_ALERT": "<strong>Sorry!<\/strong> SEED doesn't currently support that file format. Only <strong>.geojson<\/strong> and <strong>.json<\/strong> files are supported.",
"INVALID_XML_EXTENSION_ALERT": "<strong>Sorry!<\/strong> SEED doesn't currently support that file format. Only <strong>.xml<\/strong> files are supported.",
"INVALID_CSV_EXTENSION_ALERT": "<strong>Sorry!<\/strong> SEED doesn't currently support that file format. Only <strong>.csv<\/strong> files are supported.",
"INVALID_XML_ZIP_EXTENSION_ALERT": "<strong>Sorry!<\/strong> SEED doesn't currently support that file format. Only <strong>.xml<\/strong> and <strong>.zip<\/strong> files are supported.",
"IRREVERSIBLE_OPERATION_WARNING": "This operation is irreversible.",
"ITEMS_WILL_NOT_CHANGE": "these will not change",
Expand Down Expand Up @@ -444,7 +444,6 @@
"MERGE_PROTECTION_EXPLANATION": "Normally when an imported record is merged into another record the newest value overwrites an older one. Merge protection prevents this, and is particularly useful for columns where you have manually edited values that you want to persist even after importing and merging new data.",
"METER_DISPLAY_SETTINGS_TITLE": "Meter energy display units (change one at a time)",
"METER_READING_COUNTS_TITLE": "Meter Reading Counts",
"SENSOR_READING_COUNTS_TITLE": "Sensor Reading Counts",
"MJ\/\/year": "MJ\/\/year",
"MODIFYING_COLUMN_SETTINGS": "Modifying Column Settings",
"MULTIPLE_COL_MOD_OPTIONS": "From the table below, you may modify the columns in the following ways: ",
Expand Down Expand Up @@ -838,8 +837,6 @@
"UPLOAD_COMPLETE_TITLE": "Upload Complete",
"UPLOAD_FILE": "Upload File",
"UPLOAD_GB_DATA_BUTTON": "Upload GreenButton Data",
"UPLOAD_SENSOR_BUTTON": "Upload Sensor",
"UPLOAD_SENSOR_READINGS_BUTTON": "Upload Sensor Readings",
"UPLOAD_INCOMPLETE_TITLE": "Upload Incomplete",
"UPLOAD_PM_READINGS_MODAL_TITLE": "Upload Portfolio Manager Meter Readings",
"USING_DEFAULT_UNITS_WARNING": "For columns with unit settings, default units will be used for conversions.",
Expand Down
6 changes: 2 additions & 4 deletions seed/static/seed/locales/fr_CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@
"GEOCODING_NOW": "Géocodage maintenant ...",
"GJ\/\/year": "GJ\/\/année",
"GREENBUTTON_CONTENTS_TITLE": "Confirmer le contenu du fichier GreenButton",
"SENSOR_CONTENTS_TITLE": "Confirmer le contenu",
"Geocode": "Géocodage",
"Geocode Selected": "Géocode sélectionné",
"Geocoding Confidence": "Géocodage de la confiance",
Expand All @@ -363,6 +362,8 @@
"HOW THE SYSTEM AUTO-MATCHES YOUR PROPERTIES AND TAX LOTS:": "COMMENT LE SYSTÈME ADAPTE AUTOMATIQUEMENT VOS PROPRIETES ET LOTS D'IMPÔT:",
"HOW TO MANUALLY MATCH YOUR PROPERTIES AND TAX LOTS:": "COMMENT APPORTER MANUELLEMENT VOS PROPRIETES ET LOTS D'IMPÔT:",
"HOW_SYSTEM_AUTO_MATCHES_EXPLANATION": "Votre fichier de données source est présenté dans le tableau de gauche. Toutes les propriétés\/lots d'impôt où une correspondance de données possible existe sont présentées dans un tableau sur la droite. Le système tente de faire correspondre automatiquement les enregistrements à l'aide d'ID uniques partagés tels que: ID de Propriété PM, ID de Lot d'Impôt de Juridiction et les ID personnalisés, ainsi que des informations d'adresse. Lorsque le système croit qu'une correspondance existe entre un enregistrement de votre fichier source et un enregistrement existant, il vérifie automatiquement la 'correspondance' <i class=\"fa fa-check-square-o\"><\/i> case à cocher &mdash; faire efficacement une correspondance entre ces enregistrements.",
"HTTP Error! Status Code: 404. The requested URL was not found.": "Erreur HTTP! Code d'état : 404. L'URL demandée est introuvable.",
"HTTP Error! Status Code: 500. Internal Server Error.": "Erreur HTTP! Code d'état : 500. Erreur interne du serveur.",
"Hello %(first_name)s, ": "Bonjour% (first_name) s,",
"Highlights of SEED Platform™": "Points forts de la Plate-Forme SEED™",
"Home Energy Score ID": "ID de score d'énergie domestique",
Expand Down Expand Up @@ -443,7 +444,6 @@
"MERGE_PROTECTION_EXPLANATION": "Normalement, lorsqu'un enregistrement importé est fusionné dans un autre enregistrement, la valeur la plus récente remplace un enregistrement plus ancien. La protection de fusion empêche cela et est particulièrement utile pour les colonnes dans lesquelles vous avez manuellement modifié les valeurs que vous souhaitez conserver même après l'importation et la fusion de nouvelles données.",
"METER_DISPLAY_SETTINGS_TITLE": "Compteur d'énergie d'affichage (changer un à la fois)",
"METER_READING_COUNTS_TITLE": "Compte de Relevé de Compteur",
"SENSOR_READING_COUNTS_TITLE": "Compte de Relevé de Capteur",
"MJ\/\/year": "MJ\/\/année",
"MODIFYING_COLUMN_SETTINGS": "Modification des paramètres de colonne",
"MULTIPLE_COL_MOD_OPTIONS": "Dans le tableau ci-dessous, vous pouvez modifier les colonnes des manières suivantes:",
Expand Down Expand Up @@ -837,8 +837,6 @@
"UPLOAD_COMPLETE_TITLE": "Téléchargement Complet",
"UPLOAD_FILE": "Téléverser un Fichier",
"UPLOAD_GB_DATA_BUTTON": "Importer des Données GreenButton",
"UPLOAD_SENSOR_BUTTON": "Importer des Capteurs",
"UPLOAD_SENSOR_READINGS_BUTTON": "Importer des relevés des Capteurs",
"UPLOAD_INCOMPLETE_TITLE": "Téléchargement incomplet",
"UPLOAD_PM_READINGS_MODAL_TITLE": "Importer des lectures de compteur Portfolio Manager",
"USING_DEFAULT_UNITS_WARNING": "Pour les colonnes avec des paramètres d'unité, les unités par défaut seront utilisées pour les conversions.",
Expand Down
3 changes: 3 additions & 0 deletions seed/static/seed/partials/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div class="section">
<div class="section_content_container">
<div class="section_content">
<div uib-alert class="alert-danger http_error" ng-if="http_error == 404" close="closeAlert()" ><span translate>HTTP Error! Status Code: 404. The requested URL was not found.</span></div>
<div uib-alert class="alert-danger http_error" ng-if="http_error == 500" close="closeAlert()" ><span translate>HTTP Error! Status Code: 500. Internal Server Error.</span></div>


<div class="jumbotron">
<div class="home_hero_content_container">
Expand Down
4 changes: 4 additions & 0 deletions seed/static/seed/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ a:not([href]) {
}
}

.http_error {
margin: 20px;
}

.page {
clear: both;
position: relative;
Expand Down
21 changes: 0 additions & 21 deletions seed/templates/seed/404.html

This file was deleted.

21 changes: 0 additions & 21 deletions seed/templates/seed/500.html

This file was deleted.

12 changes: 3 additions & 9 deletions seed/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required, permission_required
from django.http import JsonResponse
from django.shortcuts import render
from django.shortcuts import render, redirect
from past.builtins import basestring
from rest_framework import status
from rest_framework.decorators import api_view
Expand Down Expand Up @@ -99,29 +99,23 @@ def version(request):


def error404(request, exception):
# Okay, this is a bit of a hack. Needed to move on.
if '/api/' in request.path:
return JsonResponse({
"status": "error",
"message": "Endpoint could not be found",
}, status=status.HTTP_404_NOT_FOUND)
else:
response = render(request, 'seed/404.html', {})
response.status_code = 404
return response
return redirect('/app/#?http_error=404')


def error500(request):
# Okay, this is a bit of a hack. Needed to move on.
if '/api/' in request.path:
return JsonResponse({
"status": "error",
"message": "Internal server error",
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
else:
response = render(request, 'seed/500.html', {})
response.status_code = 500
return response
return redirect('/app/#?http_error=500')


# @api_view(['POST']) # do not add api_view on this because this is public and adding it will
Expand Down

0 comments on commit 3654e12

Please sign in to comment.