Skip to content

Commit e165fa5

Browse files
committed
fixed 'page not found bug'
1 parent 8ecbd05 commit e165fa5

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

djity/project/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def update_context(self,context):
204204
# if no module name is declared we are in the project's context
205205
# for example the request might be for project.css
206206
# in this case permissions are asked for a current status of public
207-
if context['module_name'] is None:
207+
if not 'module' in context:
208208
context['perm'] = granted_perms(context['role'],settings.PUBLIC)
209209

210210
# get hierarchy of parent projects

djity/utils/decorators.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import logging
44

55
from django.http import HttpResponse,HttpResponseNotFound,HttpResponseForbidden,HttpResponseRedirect, Http404
6+
from django.shortcuts import render, render_to_response
67
from django.conf import settings
78
from django.utils.translation import ugettext_lazy as _
89
from django.contrib.auth import REDIRECT_FIELD_NAME
910
from django.utils.http import urlquote
1011
from django.contrib import messages
1112
from django.core.urlresolvers import reverse
1213

13-
from django.template import RequestContext
14+
from django.template import RequestContext, loader
1415
from djity.utils.context import DjityContext, JSTarget
1516

1617
from djity.project.models import Project
@@ -91,10 +92,6 @@ def _new_func(*args,**kwargs):
9192
# actually permissions are resolved here
9293
project.update_context(context)
9394

94-
# if module was not found by projet.update_context() raise 404
95-
if module_name and not 'module' in context:
96-
return HttpResponseRedirect(djreverse('page_not_found',context))
97-
9895
# if the user is not allowed to use this view, redirect or ask for
9996
# authentication of return error
10097
if not perm in context['perm']:
@@ -117,7 +114,16 @@ def _new_func(*args,**kwargs):
117114
context['info_message'] = request.GET['info_message']
118115

119116
kwargs['context'] = context
120-
117+
118+
# if module was not found by projet.update_context() raise 404
119+
if module_name and not 'module' in context:
120+
context.message(_("This page does not exist on this project !"))
121+
context["module"] = {'label':_('Page not found')}
122+
return render_to_response('djity/base.html',context)
123+
#t = loader.get_template('djity/base.html')
124+
#r = t.render(context)
125+
#return HttpResponseNotFound(r)
126+
121127
if 'js_target' in context:
122128
func(*args,**kwargs)
123129
return context['js_target'].json()

0 commit comments

Comments
 (0)