def get_context_data(self, **kwargs): memory = TranslationMemory() context = super(MemoryView, self).get_context_data(**kwargs) context.update(self.objects) entries = memory.list_documents(**self.objects) context['num_entries'] = len(entries) context['total_entries'] = memory.doc_count() context['delete_url'] = self.get_url('memory-delete') context['upload_url'] = self.get_url('memory-upload') context['download_url'] = self.get_url('memory-download') user = self.request.user if check_perm(user, 'memory.delete', self.objects): context['delete_form'] = DeleteForm() if check_perm(user, 'memory.edit', self.objects): context['upload_form'] = UploadForm() if 'project' in self.objects: context['import_form'] = ImportForm() context['import_url'] = self.get_url('memory-import') if 'use_file' in self.objects: context['menu_items'] = MENU context['menu_page'] = 'memory' if 'use_file' in self.objects or ( 'project' in self.objects and self.objects['project'].use_shared_tm ): context['shared_entries'] = len(memory.list_documents(use_shared=True)) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context.update(self.objects) context["num_entries"] = self.entries.count() context["entries_origin"] = self.get_origins() context["total_entries"] = Metric.objects.get_current( None, Metric.SCOPE_GLOBAL, 0, name="memory" )["memory"] context["upload_url"] = self.get_url("memory-upload") context["download_url"] = self.get_url("memory-download") user = self.request.user if check_perm(user, "memory.delete", self.objects): context["delete_url"] = self.get_url("memory-delete") if "project" in self.objects: context["rebuild_url"] = self.get_url("memory-rebuild") if check_perm(user, "memory.edit", self.objects): context["upload_form"] = UploadForm() if "from_file" in self.objects: context["menu_items"] = MENU context["menu_page"] = "memory" if "from_file" in self.objects or ( "project" in self.objects and self.objects["project"].use_shared_tm ): context["shared_entries"] = Memory.objects.filter(shared=True).count() return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context.update(self.objects) entries = Memory.objects.filter_type(**self.objects) context["num_entries"] = entries.count() context["total_entries"] = Memory.objects.all().count() context["upload_url"] = self.get_url("memory-upload") context["download_url"] = self.get_url("memory-download") user = self.request.user if check_perm(user, "memory.edit", self.objects): context["upload_form"] = UploadForm() if "from_file" in self.objects: context["menu_items"] = MENU context["menu_page"] = "memory" if "from_file" in self.objects or ( "project" in self.objects and self.objects["project"].use_shared_tm ): context["shared_entries"] = Memory.objects.filter(shared=True).count() return context