changeset 2961:08f89c688592 beta

deleting a group now does same archive operation like deleting repositories. Improve prompt that show number of repos that will be archived together with a group.
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 26 Oct 2012 00:13:55 +0200
parents 91d5f720e88f
children c400f2fbf131
files rhodecode/model/repos_group.py rhodecode/templates/admin/repos_groups/repos_groups_show.html
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/model/repos_group.py	Thu Oct 25 23:40:16 2012 +0200
+++ b/rhodecode/model/repos_group.py	Fri Oct 26 00:13:55 2012 +0200
@@ -27,6 +27,7 @@
 import logging
 import traceback
 import shutil
+import datetime
 
 from rhodecode.lib.utils2 import LazyProperty
 
@@ -126,12 +127,18 @@
         paths = os.sep.join(paths)
 
         rm_path = os.path.join(self.repos_path, paths)
+        log.info("Removing group %s" % (rm_path))
+        # delete only if that path really exists
         if os.path.isdir(rm_path):
-            # delete only if that path really exists
             if force_delete:
                 shutil.rmtree(rm_path)
             else:
-                os.rmdir(rm_path)  # this raises an exception when there are still objects inside
+                #archive that group`
+                _now = datetime.datetime.now()
+                _ms = str(_now.microsecond).rjust(6, '0')
+                _d = 'rm__%s_GROUP_%s' % (_now.strftime('%Y%m%d_%H%M%S_' + _ms),
+                                          group.name)
+                shutil.move(rm_path, os.path.join(self.repos_path, _d))
 
     def create(self, group_name, group_description, parent=None, just_db=False):
         try:
--- a/rhodecode/templates/admin/repos_groups/repos_groups_show.html	Thu Oct 25 23:40:16 2012 +0200
+++ b/rhodecode/templates/admin/repos_groups/repos_groups_show.html	Fri Oct 26 00:13:55 2012 +0200
@@ -40,6 +40,7 @@
                 ## REPO GROUPS
 
                 % for gr in c.groups:
+                    <% gr_cn = gr.repositories.count() %>
                   <tr>
                       <td>
                           <div style="white-space: nowrap">
@@ -48,10 +49,10 @@
                           </div>
                       </td>
                       <td>${gr.group_description}</td>
-                      <td><b>${gr.repositories.count()}</b></td>
+                      <td><b>${gr_cn}</b></td>
 		               <td>
 		                 ${h.form(url('repos_group', id=gr.group_id),method='delete')}
-		                   ${h.submit('remove_%s' % gr.name,_('delete'),class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this group: %s') % gr.name+"');")}
+		                   ${h.submit('remove_%s' % gr.name,_('delete'),class_="delete_icon action_button",onclick="return confirm('"+ungettext('Confirm to delete this group: %s with %s repository','Confirm to delete this group: %s with %s repositories',gr_cn) % (gr.name,gr_cn)+"');")}
 		                 ${h.end_form()}
 		               </td>
                   </tr>