This is an automated email from the ASF dual-hosted git repository.

gcruz pushed a commit to branch gc/8577
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/gc/8577 by this push:
     new bb88df871 fixup! [#8577] notes can be added to a project in the new 
projects section
bb88df871 is described below

commit bb88df871845800b0660082a46e086978461c617
Author: Guillermo Cruz <[email protected]>
AuthorDate: Fri Apr 25 12:54:05 2025 -0600

    fixup! [#8577] notes can be added to a project in the new projects section
---
 Allura/allura/controllers/site_admin.py              |  2 +-
 Allura/allura/templates/site_admin_new_projects.html | 13 +++++++++----
 Allura/allura/tests/functional/test_site_admin.py    |  8 +++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Allura/allura/controllers/site_admin.py 
b/Allura/allura/controllers/site_admin.py
index ec0b83194..537536fc5 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -221,7 +221,7 @@ def save_project_note(self, **kwargs):
         nbhd = M.Neighborhood.query.get(name='Projects')
         c.project = M.Project.query.get(shortname=shortname, 
neighborhood_id=nbhd._id)
         if c.project and note:
-            c.project.set_tool_data('allura', notes=note)
+            c.project.set_tool_data('notes', note=note)
             return {'status': 'ok', 'message': 'Project note updated'}
         return {'status': 'error', 'message': 'Project note not updated'}
 
diff --git a/Allura/allura/templates/site_admin_new_projects.html 
b/Allura/allura/templates/site_admin_new_projects.html
index 9ba018926..8970ff2e3 100644
--- a/Allura/allura/templates/site_admin_new_projects.html
+++ b/Allura/allura/templates/site_admin_new_projects.html
@@ -73,10 +73,11 @@
     </tr>
     <tr class="tablesorter-childRow">
         <td colspan="8" class="child-row">
-            {% if p.get_tool_data('allura', 'notes') %}
-                <strong>Notes:</strong> {{ p.get_tool_data('allura', 'notes') 
}}
-            {% else %}
-                <a class="add-note" title="click to add a not for this 
project" data-project="{{ p.shortname }}" href="#"><i class="fa fa-edit"></i> 
add note</a>
+            {% set note = p.get_tool_data('notes', 'note') %}
+            <a class="add-note" title="click to add a not for this project" 
data-project="{{ p.shortname }}" href="#"><i class="fa fa-edit"></i> {% if note 
%}edit note{% else %}add note{%endif %}</a>
+            <br>
+            {% if note %}
+                <strong>Notes:</strong> <span class="project-note">{{ note 
}}</span>
             {% endif %}
         </td>
     </tr>
@@ -144,6 +145,7 @@
             evt.preventDefault();
             var project_shortname = el.data('project');
             var form_exists = el.closest('tr').find('td:first').find('form');
+            var notes = el.closest('tr').find('td:first').find('.project-note')
            if (form_exists.length > 0) {
                return;
            }
@@ -152,6 +154,9 @@
             var submit_btn = $('<button type="submit" class="button blue 
right">Submit</button>');
             var cancel_btn = $('<button class="" >Cancel</button>');
             var div = $('<div class="note-buttons"></div>')
+            if (notes){
+                textarea.val(notes.text());
+            }
             form.append(textarea)
             div.append(submit_btn);
             div.append(cancel_btn);
diff --git a/Allura/allura/tests/functional/test_site_admin.py 
b/Allura/allura/tests/functional/test_site_admin.py
index d9767e8fd..ad44eafdc 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -179,7 +179,13 @@ def test_task_doc(self):
         r = self.app.get('/nf/admin/task_manager/task_doc', params=dict(
             task_name='allura.tests.functional.test_site_admin.test_task'))
         assert json.loads(r.text)['doc'] == 'test_task doc string'
-
+    
+    def test_project_note(self):
+        note_content = 'this is a test note for project'
+        r = self.app.post('/nf/admin/save_project_note', 
params=dict(shortname='test', note=note_content), status=200)
+        project = M.Project.query.get(shortname='test')
+        assert note_content == project.get_tool_data('notes', 'note')
+        
 
 class TestSiteAdminNotifications(TestController):
 

Reply via email to