Exemple #1
0
 def form_valid(self, form):
     if not check_perm(self.request.user, 'memory.delete', self.objects):
         raise PermissionDenied()
     memory = TranslationMemory()
     memory.delete(**self.objects)
     messages.success(self.request, _('Entries deleted.'))
     return super(DeleteView, self).form_valid(form)
Exemple #2
0
 def test_delete(self):
     self.add_document()
     memory = TranslationMemory()
     self.assertEqual(memory.doc_count(), 1)
     self.assertEqual(memory.delete('test'), 1)
     self.assertEqual(memory.delete('missing'), 0)
     memory = TranslationMemory()
     self.assertEqual(memory.doc_count(), 0)
Exemple #3
0
 def form_valid(self, form):
     if not check_perm(self.request.user, 'memory.delete', self.objects):
         raise PermissionDenied()
     memory = TranslationMemory()
     memory.delete(**self.objects)
     messages.success(
         self.request, _('Entries deleted.')
     )
     return super(DeleteView, self).form_valid(form)
Exemple #4
0
 def handle(self, *args, **options):
     """Translation memory cleanup."""
     memory = TranslationMemory()
     if options['all']:
         memory.empty()
     elif options['origin'] or options['category']:
         memory.delete(options['origin'], options['category'])
     else:
         raise CommandError('Please specify what you want to delete')
Exemple #5
0
 def handle(self, *args, **options):
     """Translation memory cleanup."""
     memory = TranslationMemory()
     if options['all']:
         memory.empty()
     elif options['origin'] or options['category']:
         memory.delete(options['origin'], options['category'])
     else:
         raise CommandError('Please specify what you want to delete')