Browse Source

moved POST api to the api.py controller + rename dashboard to document

damien 11 years ago
parent
commit
418e459ad3

+ 52 - 2
pboard/pboard/controllers/api.py View File

@@ -39,7 +39,7 @@ class PODApiController(BaseController):
39 39
         loNewNode.data_reminder_datetime = data_reminder_datetime
40 40
 
41 41
       pm.DBSession.flush()
42
-      redirect(lurl('/dashboard?node=%i'%(loNewNode.parent_id)))
42
+      redirect(lurl('/document/%i'%(loNewNode.parent_id)))
43 43
 
44 44
     @expose()
45 45
     def set_parent_node(self, node_id, new_parent_id, **kw):
@@ -47,6 +47,56 @@ class PODApiController(BaseController):
47 47
       if new_parent_id!='':
48 48
         loNewNode.parent_id = int(new_parent_id)
49 49
       pm.DBSession.flush()
50
-      redirect(lurl('/dashboard?node=%s'%(node_id)))
50
+      redirect(lurl('/document/%s'%(node_id)))
51 51
 
52
+    @expose()
53
+    def move_node_upper(self, node_id=0, came_from=lurl('/dashboard')):
54
+      loNode = pld.getNode(node_id)
55
+      pld.moveNodeUpper(loNode)
56
+      redirect(came_from)
57
+
58
+    @expose()
59
+    def move_node_lower(self, node_id=0, came_from=lurl('/dashboard')):
60
+      loNode = pld.getNode(node_id)
61
+      pld.moveNodeLower(loNode)
62
+      redirect(came_from)
63
+
64
+    @expose()
65
+    def create_document(self, parent_id=None):
66
+      loNewNode = pld.createNode()
67
+      loNewNode.data_label   = 'New document'
68
+      loNewNode.data_content = 'insert content...'
69
+      if int(parent_id)==0:
70
+        loNewNode.parent_id = None
71
+      else:
72
+        loNewNode.parent_id = parent_id
73
+
74
+      DBSession.flush()
75
+      redirect(lurl('/document/%i'%(loNewNode.node_id)))
76
+
77
+    @expose()
78
+    def edit_label(self, node_id, data_label):
79
+      loNewNode = pld.getNode(node_id)
80
+      loNewNode.data_label   = data_label
81
+      redirect(lurl('/document/%s'%(node_id)))
82
+
83
+    @expose()
84
+    def edit_status(self, node_id, node_status):
85
+      loNewNode = pld.getNode(node_id)
86
+      loNewNode.node_status = node_status
87
+      redirect(lurl('/document/%s'%(node_id)))
88
+
89
+    @expose()
90
+    def edit_content(self, node_id, data_content, **kw):
91
+      loNewNode = pld.getNode(node_id)
92
+      loNewNode.data_content = data_content
93
+      redirect(lurl('/document/%s'%(node_id)))
94
+
95
+    @expose()
96
+    def force_delete_node(self, node_id=None):
97
+      loNode     = pld.getNode(node_id)
98
+      liParentId = loNode.parent_id
99
+      if loNode.getChildNb()<=0:
100
+        DBSession.delete(loNode)
101
+      redirect(lurl('/document/%i'%(liParentId or 0)))
52 102
 

+ 3 - 56
pboard/pboard/controllers/root.py View File

@@ -118,68 +118,15 @@ class RootController(BaseController):
118 118
         flash(_('We hope to see you soon!'))
119 119
         redirect(came_from)
120 120
         
121
-    @expose('pboard.templates.dashboard')
122
-    def dashboard(self, node=0, came_from=lurl('/')):
121
+    @expose('pboard.templates.document')
122
+    def document(self, node=0, came_from=lurl('/')):
123 123
         """show the user dashboard"""
124 124
         import pboard.model.data as pbmd
125 125
         loRootNodeList = pbm.DBSession.query(pbmd.PBNode).filter(pbmd.PBNode.parent_id==None).order_by(pbmd.PBNode.node_order).all()
126
-        liNodeId = max(int(node), 1)
127
-        print "{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}", liNodeId
128
-        # liNodeId = 5
126
+        liNodeId         = max(int(node), 1) # show node #1 if no selected node
129 127
         loCurrentNode    = pbm.DBSession.query(pbmd.PBNode).filter(pbmd.PBNode.node_id==liNodeId).one()
130 128
         loNodeStatusList = pbmd.PBNodeStatus.getList()
131 129
         return dict(root_node_list=loRootNodeList, current_node=loCurrentNode, node_status_list = loNodeStatusList)
132 130
 
133
-    @expose()
134
-    def move_node_upper(self, node_id=0, came_from=lurl('/dashboard')):
135
-      loNode = pld.getNode(node_id)
136
-      pld.moveNodeUpper(loNode)
137
-      redirect(came_from)
138
-
139
-    @expose()
140
-    def move_node_lower(self, node_id=0, came_from=lurl('/dashboard')):
141
-      loNode = pld.getNode(node_id)
142
-      pld.moveNodeLower(loNode)
143
-      redirect(came_from)
144
-
145
-    @expose()
146
-    def create_document(self, parent_id=None):
147
-      loNewNode = pld.createNode()
148
-      loNewNode.data_label   = 'New document'
149
-      loNewNode.data_content = 'insert content...'
150
-      if int(parent_id)==0:
151
-        loNewNode.parent_id = None
152
-      else:
153
-        loNewNode.parent_id = parent_id
154
-
155
-      DBSession.flush()
156
-      redirect(lurl('/dashboard?node=%i'%(loNewNode.node_id)))
157
-
158
-    @expose()
159
-    def edit_label(self, node_id, data_label):
160
-      loNewNode = pld.getNode(node_id)
161
-      loNewNode.data_label   = data_label
162
-      redirect(lurl('/dashboard?node=%s'%(node_id)))
163
-
164
-    @expose()
165
-    def edit_status(self, node_id, node_status):
166
-      loNewNode = pld.getNode(node_id)
167
-      loNewNode.node_status = node_status
168
-      redirect(lurl('/dashboard?node=%s'%(node_id)))
169
-
170
-    @expose()
171
-    def edit_content(self, node_id, data_content, **kw):
172
-      loNewNode = pld.getNode(node_id)
173
-      loNewNode.data_content = data_content
174
-      redirect(lurl('/dashboard?node=%s'%(node_id)))
175
-
176
-    @expose()
177
-    def force_delete_node(self, node_id=None):
178
-      loNode     = pld.getNode(node_id)
179
-      liParentId = loNode.parent_id
180
-      if loNode.getChildNb()<=0:
181
-        DBSession.delete(loNode)
182
-      redirect(lurl('/dashboard?node=%i'%(liParentId or 0)))
183
-
184 131
 
185 132
 

+ 9 - 0
pboard/pboard/model/data.py View File

@@ -1,5 +1,14 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 """
3
+
4
+Search activity on the dashboard:
5
+select node_id, node_type, created_at as last_action, data_label, 'new data' as label from pb_nodes where updated_at=created_at
6
+union
7
+select node_id, node_type, updated_at as last_action, data_label, 'updated data' as label from pb_nodes where updated_at>created_at
8
+union
9
+select node_id, node_type, data_datetime as last_action, data_label, 'event' as label from pb_nodes where node_type='event'
10
+order by last_action desc
11
+
3 12
 """
4 13
 import os
5 14
 import re

pboard/pboard/templates/dashboard.mak → pboard/pboard/templates/document.mak View File

@@ -4,7 +4,7 @@
4 4
 
5 5
 <%def name="node_treeview_for_set_parent_menu(node_id, node_list, indentation=-1)">
6 6
   % if indentation==-1:
7
-    <li><a href="${tg.url('/api/set_parent_node?node_id=%i&new_parent_id=0'%(current_node.node_id))}">${_('Root')}</a>
7
+    <li><a href="${tg.url('/api/set_parent_node?node_id=%i&new_parent_id=0'%(current_node.node_id))}">${_('Home')}</a>
8 8
       ${node_treeview_for_set_parent_menu(node_id, node_list, 0)}
9 9
     </li>
10 10
   % else:
@@ -29,7 +29,7 @@
29 29
         ${_('Root')}
30 30
       </a>
31 31
       <div class="pod-toolbar">
32
-        <a href="${tg.url('/create_document?parent_id=0')}" title="${_('Add child document')}"><i class="icon-g-circle-plus"></i></a>
32
+        <a href="${tg.url('/api/create_document?parent_id=0')}" title="${_('Add child document')}"><i class="icon-g-circle-plus"></i></a>
33 33
       </div>
34 34
     </div>
35 35
     ${node_treeview(node_list, 0)}
@@ -47,9 +47,9 @@
47 47
             % endif
48 48
           </a>
49 49
           <div class="pod-toolbar">
50
-            <a href="${tg.url('/move_node_upper?node_id=%i'%(node.node_id))}" title="${_('Move up')}"><i class="icon-g-up-arrow"></i></a>
51
-            <a href="${tg.url('/move_node_lower?node_id=%i'%(node.node_id))}" title="${_('Move down')}"><i class="icon-g-down-arrow"></i></a>
52
-            <a href="${tg.url('/create_document?parent_id=%i'%(node.node_id))}" title="${_('Add child document')}"><i class="icon-g-circle-plus"></i></a>
50
+            <a href="${tg.url('/api/move_node_upper?node_id=%i'%(node.node_id))}" title="${_('Move up')}"><i class="icon-g-up-arrow"></i></a>
51
+            <a href="${tg.url('/api/move_node_lower?node_id=%i'%(node.node_id))}" title="${_('Move down')}"><i class="icon-g-down-arrow"></i></a>
52
+            <a href="${tg.url('/api/create_document?parent_id=%i'%(node.node_id))}" title="${_('Add child document')}"><i class="icon-g-circle-plus"></i></a>
53 53
           </div>
54 54
           <div class="pod-status ${node.getStatus().css}" title='${node.getStatus().label}'>
55 55
              <i class='${node.getStatus().icon}'></i>
@@ -129,12 +129,12 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
129 129
         </ul>
130 130
 
131 131
 
132
-        <a href='${tg.url('/force_delete_node?node_id=%i'%(current_node.node_id))}' id='current-document-force-delete-button' class="btn" onclick="return confirm('${_('Delete current document?')}');"><i class="icon-g-remove"></i> ${_('Delete')}</a>
132
+        <a href='${tg.url('/api/force_delete_node?node_id=%i'%(current_node.node_id))}' id='current-document-force-delete-button' class="btn" onclick="return confirm('${_('Delete current document?')}');"><i class="icon-g-remove"></i> ${_('Delete')}</a>
133 133
       </div>
134 134
       
135 135
             <!--</div> PAGE HEADER -->
136 136
       <h3 id="current-document-title">#${current_node.node_id} - ${current_node.data_label}</h3>
137
-        <form style='display: none; margin-top: 1em;' id="current-document-title-edit-form" method='post' action='${tg.url('/edit_label')}'>
137
+        <form style='display: none; margin-top: 1em;' id="current-document-title-edit-form" method='post' action='${tg.url('/api/edit_label')}'>
138 138
           <div class="input-prepend input-append">
139 139
             <input type='hidden' name='node_id' value='${current_node.node_id}'/>
140 140
             ${POD.CancelButton('current-document-title-edit-cancel-button')}
@@ -148,7 +148,7 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
148 148
         <div id='current-document-content' class="">
149 149
           ${current_node.getContentWithTags()|n}
150 150
         </div>
151
-        <form style='display: none;' id="current-document-content-edit-form" method='post' action='${tg.url('/edit_content')}'>
151
+        <form style='display: none;' id="current-document-content-edit-form" method='post' action='${tg.url('/api/edit_content')}'>
152 152
           <input type='hidden' name='node_id' value='${current_node.node_id}'/>
153 153
           <textarea id="current_node_textarea" name='data_content' spellcheck="false" wrap="off" autofocus placeholder="Enter something ...">
154 154
             ${current_node.data_content|n}