From 8f56416234be1ef5657a6afe77fd7f345fb2a5b4 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 21 Apr 2023 15:45:07 +0500 Subject: [PATCH 1/4] Custom 404 page added --- src/apps/pages/views.py | 7 +++++++ src/static/img/404.png | Bin 0 -> 5087 bytes src/templates/404.html | 12 ++++++++++++ src/urls.py | 3 +++ 4 files changed, 22 insertions(+) create mode 100644 src/static/img/404.png create mode 100644 src/templates/404.html diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index 971909972..5816a5654 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -8,6 +8,7 @@ from competitions.models import Competition, Submission, CompetitionParticipant from profiles.models import User +from django.shortcuts import render class HomeView(TemplateView): template_name = 'pages/home.html' @@ -62,3 +63,9 @@ def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['submissions'] = qs[:250] return context + + +def page_not_found_view(request, exception): + print(request) + return render(request, '404.html', status=404) + \ No newline at end of file diff --git a/src/static/img/404.png b/src/static/img/404.png new file mode 100644 index 0000000000000000000000000000000000000000..510337e88008b274ca972fe5c033398972dfa058 GIT binary patch literal 5087 zcmds5hg(zIvIkMxIW&lgO(4<) z=_N>u)X*Uy1i^qL0&jEA{mwhz`|kY*-u~8JnLYEHS?f15d+#KPca3hbFrR0pp`l@c z>S>$M(42w+aw#JnFt-w`!+;N3Ka*RUv=cp$DByzWk)EX=4GlN=&5iS=LOFC`!Y zE`I}nIFN!q$=CnZ06_%rM@tmoAO!F?$K zQvM(7Kau}$WaX}7U?_GSD|8+IMM|;bSgGq|D0ZHh0O8+yK<+$||C-fXPE0EQ(%{}{ zOaTUzzlo74%~kd2R)lbL>s<$S_Sf|5$46JTk1-FbUpt(hyFRCWY}+pU=qh54cJj8# z#8AJD?()#1)`yB)Otle^J&w|34ET_Ge*0A#n(Jz6pV)9)!`syo!O5=a zgTczOx$_O-Bx(GQ=Pm`i;TDRDio;93f2Hp~&%=)30{b3{d^CSt_?u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gi`;8n6C%5gdn|}H=$-T|Z?jr%nxDcaYZI{MAUpU;dUbSByNNo`2k%L4 zGE-7c5U|g(=W6QAwEJB8SNE5&(`*2Tv}U1x9a%1!n>$N9!7-o9&>YB|+Xk4-c3HCs zrW2BB&1!WbF@9o5qY}@e(jj6f>CETgeXsEVQxS;x2 zaD)Cbl#oJhtD=*VOS&3>1GzyvzTW_9b9tUh9PN!@eG!nL!wUQ|qgKhn7ZmtkfmJV` zv}-I$-=d zjc~^X8b>>ocu7gFS@pxSHJKlbKq}5UHS-X~$%nKYUO6;vy{y0`JZ7D$B|a@f1N1Bt zHBvd_$H>~W)co%3HH+y60Vmrl)-vmKKoVmkq9O|=rC$lKNMGmd3aNMTza0zkBMNT7 zvK>~Zka7kw?bUv7oh|}#5~-0zJ-SFvxJu`^FGLu{pElv(AeQh!uVB(=4Dv%;^jFJ* ziS?SBBKnlPs?k=&bzX(Ih&9ZA{*U0lYnObF&(vL2>a#lQoq2+S>KJLGH63F92OLZ^ AZvX%Q literal 0 HcmV?d00001 diff --git a/src/templates/404.html b/src/templates/404.html new file mode 100644 index 000000000..e4bfe0faf --- /dev/null +++ b/src/templates/404.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + + +{% block content %} +
+ +

Could not find the page you requested.

+

If you are the challenge organizer and this URL previously pointed to a valid competition and it is now missing please contact us at info@codabench.org for more information.

+

If this is an error, please file a bug report. For more information about Codabench, check out the wiki.

+ Return to Home +
+{% endblock %} diff --git a/src/urls.py b/src/urls.py index ea610fd46..05f186f6a 100644 --- a/src/urls.py +++ b/src/urls.py @@ -1,5 +1,6 @@ from django.conf import settings from django.conf.urls import include +from django.conf.urls import handler404 from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import path @@ -32,6 +33,8 @@ path('social/', include('social_django.urls', namespace='social')), ] +handler404 = "pages.views.page_not_found_view" + if settings.DEBUG: # Static files for local dev, so we don't have to collectstatic and such From e0d66a2b80bcfdf21f37f9031e52a7d46321d955 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 21 Apr 2023 15:52:15 +0500 Subject: [PATCH 2/4] circle ci spaces issues resolved --- src/apps/pages/views.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index 5816a5654..d4fa9bd44 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -10,6 +10,7 @@ from django.shortcuts import render + class HomeView(TemplateView): template_name = 'pages/home.html' @@ -63,9 +64,7 @@ def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['submissions'] = qs[:250] return context - def page_not_found_view(request, exception): print(request) - return render(request, '404.html', status=404) - \ No newline at end of file + return render(request, '404.html', status=404) \ No newline at end of file From 9584e90d84023ad61229ca58da6fdc548d5de060 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Fri, 21 Apr 2023 15:58:26 +0500 Subject: [PATCH 3/4] circle ci line breaks fixed --- src/apps/pages/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index d4fa9bd44..19c9a1172 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -63,8 +63,9 @@ def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['submissions'] = qs[:250] - return context + return context + def page_not_found_view(request, exception): print(request) - return render(request, '404.html', status=404) \ No newline at end of file + return render(request, '404.html', status=404) From 3e45f4d3e592e98bbd581e6eecf09643ee7e32f4 Mon Sep 17 00:00:00 2001 From: didayolo Date: Fri, 21 Apr 2023 14:45:11 +0200 Subject: [PATCH 4/4] Fix return home and code formatting --- src/apps/pages/views.py | 2 +- src/templates/404.html | 2 +- src/urls.py | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/apps/pages/views.py b/src/apps/pages/views.py index 19c9a1172..e73c276b4 100644 --- a/src/apps/pages/views.py +++ b/src/apps/pages/views.py @@ -63,7 +63,7 @@ def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) context['submissions'] = qs[:250] - return context + return context def page_not_found_view(request, exception): diff --git a/src/templates/404.html b/src/templates/404.html index e4bfe0faf..ce2b6a226 100644 --- a/src/templates/404.html +++ b/src/templates/404.html @@ -7,6 +7,6 @@

Could not find the page you requested.

If you are the challenge organizer and this URL previously pointed to a valid competition and it is now missing please contact us at info@codabench.org for more information.

If this is an error, please file a bug report. For more information about Codabench, check out the wiki.

- Return to Home + Return to Home {% endblock %} diff --git a/src/urls.py b/src/urls.py index 05f186f6a..ea610fd46 100644 --- a/src/urls.py +++ b/src/urls.py @@ -1,6 +1,5 @@ from django.conf import settings from django.conf.urls import include -from django.conf.urls import handler404 from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import path @@ -33,8 +32,6 @@ path('social/', include('social_django.urls', namespace='social')), ] -handler404 = "pages.views.page_not_found_view" - if settings.DEBUG: # Static files for local dev, so we don't have to collectstatic and such