Przeglądaj źródła

[doc2] Update name of file when moving it

Romain Rigaux 9 lat temu
rodzic
commit
21cca5a

+ 1 - 0
desktop/core/src/desktop/api2.py

@@ -171,6 +171,7 @@ def move_document(request):
     raise PopupException(_('Destination is not a directory'))
 
   source.move(destination, request.user)
+  source.save()
 
   return JsonResponse({'status': 0})
 

+ 2 - 0
desktop/core/src/desktop/models.py

@@ -919,6 +919,8 @@ class Document2(models.Model):
     if directory.can_write_or_exception(user=user):
       directory.dependencies.add(self)
 
+    self.name = directory.name + '/' + self.name.rsplit('/', 1)[1]
+ 
   def share(self, user, name='read', users=None, groups=None):
     # TODO check in settings if user can sync, re-share, which perms...