You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2025/04/24 17:09:02 UTC
(allura) 01/01: [#8577] notes can be added to a project in the new projects section
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
commit a2a0999d31b90154c57f0f3432bd1873a478c282
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Thu Apr 24 11:08:32 2025 -0600
[#8577] notes can be added to a project in the new projects section
---
Allura/allura/controllers/site_admin.py | 12 +++++
.../allura/templates/site_admin_new_projects.html | 53 ++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index a4af8ecad..ec0b83194 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -213,6 +213,18 @@ def new_projects(self, **kwargs):
'window_end': end_dt,
}
+ @expose('json:')
+ @require_post()
+ def save_project_note(self, **kwargs):
+ shortname = kwargs.get('shortname')
+ note = kwargs.get('note')
+ 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)
+ return {'status': 'ok', 'message': 'Project note updated'}
+ return {'status': 'error', 'message': 'Project note not updated'}
+
@expose('jinja:allura:templates/site_admin_reclone_repo.html')
@without_trailing_slash
@validate(dict(prefix=validators.NotEmpty(),
diff --git a/Allura/allura/templates/site_admin_new_projects.html b/Allura/allura/templates/site_admin_new_projects.html
index 413b43720..9ba018926 100644
--- a/Allura/allura/templates/site_admin_new_projects.html
+++ b/Allura/allura/templates/site_admin_new_projects.html
@@ -71,6 +71,15 @@
<td><small>{{ p.external_homepage|urlize(22) }}</small></td>
<td>{% for a in p.admins() %}<small><a href="/nf/admin/user/{{ a.username }}">{{ a.username }}</a></small> {% endfor %}</td>
</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>
+ {% endif %}
+ </td>
+ </tr>
{% endfor %}
</table>
{{ _paging() }}
@@ -110,6 +119,11 @@
background-position: 100% 50%;
background-color: #6bb3fd;
}
+ td.child-row{ text-align:center}
+ .note-buttons{
+ display: flex;
+ justify-content: center;
+ }
</style>
{% endblock %}
@@ -124,5 +138,44 @@
sortRestart : false
});
});
+ $('.add-note').each(function(el){
+ var el = $(this);
+ el.on('click', function(evt){
+ evt.preventDefault();
+ var project_shortname = el.data('project');
+ var form_exists = el.closest('tr').find('td:first').find('form');
+ if (form_exists.length > 0) {
+ return;
+ }
+ var form = $('<form></form>')
+ var textarea = $('<textarea class="note" rows="5" cols="100"></textarea>');
+ 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>')
+ form.append(textarea)
+ div.append(submit_btn);
+ div.append(cancel_btn);
+ form.append(div);
+ el.closest('tr').find('td:first').append(form)
+ form.on('submit', function(evt){
+ evt.preventDefault();
+ var url = "{{ request.path.replace('new_projects', 'save_project_note')}}";
+ var data = {'_csrf_token': $.cookie('_csrf_token'), 'note': textarea.val(), 'shortname': project_shortname}
+ $.post(url,data).done(function(response){
+ flash(response.message, 'success');
+ form.remove();
+ var td = el.closest('tr').find('td:first');
+ td.html('<p><strong>Notes:</strong>' + textarea.val() + '</p>');
+ el.remove();
+ }).fail(function (response){
+ flash(response.message, 'error');
+ })
+ })
+ cancel_btn.on('click', function(evt){
+ evt.preventDefault();
+ form.remove();
+ })
+ })
+ })
} );</script>
{% endblock %}