Browse Source

fixes a wrong way to show content instead of requested document when the document did not exist

damien 11 years ago
parent
commit
1639e8a7c4
1 changed files with 6 additions and 0 deletions
  1. 6 0
      pboard/pboard/controllers/root.py

+ 6 - 0
pboard/pboard/controllers/root.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 """Main Controller"""
2
 """Main Controller"""
3
 
3
 
4
+import tg
4
 from tg import expose, flash, require, url, lurl, request, redirect, tmpl_context
5
 from tg import expose, flash, require, url, lurl, request, redirect, tmpl_context
5
 from tg.i18n import ugettext as _, lazy_ugettext as l_
6
 from tg.i18n import ugettext as _, lazy_ugettext as l_
6
 from tg import predicates
7
 from tg import predicates
123
         
124
         
124
         # FIXME - D.A - 2013-11-07 - Currently, the code build a new item if no item found for current user
125
         # FIXME - D.A - 2013-11-07 - Currently, the code build a new item if no item found for current user
125
         # the correct behavior should be to redirect to setup page
126
         # the correct behavior should be to redirect to setup page
127
+        if loCurrentNode is not None and "%s"%loCurrentNode.node_id!=node:
128
+          redirect(tg.url('/document/%i'%loCurrentNode.node_id))
129
+          
126
         if loCurrentNode is None:
130
         if loCurrentNode is None:
127
           loCurrentNode = loApiController.getNode(0) # try to get an item
131
           loCurrentNode = loApiController.getNode(0) # try to get an item
128
           if loCurrentNode is not None:
132
           if loCurrentNode is not None:
129
             flash(_('Document not found. Randomly showing item #%i')%(loCurrentNode.node_id), 'warning')
133
             flash(_('Document not found. Randomly showing item #%i')%(loCurrentNode.node_id), 'warning')
134
+            redirect(tg.url('/document/%i'%loCurrentNode.node_id))
130
           else:
135
           else:
131
             flash(_('Your first document has been automatically created'), 'info')
136
             flash(_('Your first document has been automatically created'), 'info')
132
             loCurrentNode = loApiController.createDummyNode()
137
             loCurrentNode = loApiController.createDummyNode()
133
             pm.DBSession.flush()
138
             pm.DBSession.flush()
139
+            redirect(tg.url('/document/%i'%loCurrentNode.node_id))
134
 
140
 
135
         return dict(root_node_list=loRootNodeList, current_node=loCurrentNode, node_status_list = loNodeStatusList)
141
         return dict(root_node_list=loRootNodeList, current_node=loCurrentNode, node_status_list = loNodeStatusList)
136
 
142