def __init__(self, *args, **kwargs): super(PublishingForm, self).__init__(*args, **kwargs) # if we don't have external (additional) converters enabled, # we must hide this options from form # TODO: we can make a generic solution, create form elements based on available converters converters = convert_loader.find_all( module_names=convert_utils.get_converter_module_names()) if 'pdfreactor-screenpdf' not in converters: del self.fields['publish_pdfreactor_screenpdf'] if 'pdfreactor' not in converters: del self.fields['publish_pdfreactor']
def __init__(self): celery.Task.__init__(self) os.putenv("LC_ALL", "en_US.UTF-8") self.converters = loader.find_all( module_names=utils.get_converter_module_names())
def get_converters(): return convert_loader.find_all(module_names=convert_utils.get_converter_module_names())
def get_converters(): return convert_loader.find_all( module_names=convert_utils.get_converter_module_names())
def get_context_data(self, **kwargs): context = super(TemplateView, self).get_context_data(**kwargs) try: book = models.Book.objects.get(url_title__iexact=kwargs['bookid']) except models.Book.DoesNotExist: return {'book': None, 'book_id': kwargs['bookid']} book_version = book.get_version(None) toc = get_toc_for_book(book_version) context['request'] = self.request context['book'] = book context['book_version'] = book_version.get_version() context['book_language'] = book.language.abbrevation if book.language else 'en' context['security'] = self.security try: rtl = models.Info.objects.get(book=book, kind=0, name='{http://booki.cc/}dir') context['book_dir'] = rtl.get_value().lower() except models.Info.DoesNotExist: context['book_dir'] = 'ltr' context['chapters'] = toc # check if we should track changes for current user user_permissions = get_user_permissions(self.request.user, book) context['track_changes_approve'] = self.security.has_perm('edit.track_changes_approve') context['track_changes_enable'] = self.security.has_perm('edit.track_changes_enable') should_track_changes = 'edit.track_changes' in user_permissions context['track_changes'] = json.dumps( book_version.track_changes or should_track_changes) context['is_admin'] = self.security.is_admin() context['is_owner'] = book.owner == self.request.user context['icc_profiles_choices'] = config.get_configuration('ICC_PROFILES_CHOICES', None) # publish options are used in panel_publish.html to render available converters publish_options = config.get_configuration('PUBLISH_OPTIONS') context['publish_options'] = publish_options context['page_size_data'] = config.get_configuration('PAGE_SIZE_DATA') outputs_map = {} converters = convert_loader.find_all( module_names=convert_utils.get_converter_module_names()) for output_key in publish_options: # if saved option is not in converters, let's just ignore it if output_key not in converters: continue converter_class = converters[output_key] support_section_settings = getattr(converter_class, 'support_section_settings', False) if not support_section_settings: continue safe_key = output_key.replace('-', '_') outputs_map[safe_key] = getattr(converter_class, 'verbose_name', output_key) context['publish_options_ordered_tuple'] = sorted(outputs_map.items(), key=operator.itemgetter(1)) context['TocSettings'] = TocSettings context['autosave'] = json.dumps({ 'enabled': config.get_configuration('EDITOR_AUTOSAVE_ENABLED'), 'delay': config.get_configuration('EDITOR_AUTOSAVE_DELAY') }) context['settings_roles_show_permissions'] = config.get_configuration('EDITOR_SETTINGS_ROLES_SHOW_PERMISSIONS') context['upload_docx_form'] = UploadDocxFileForm() # get book participants members_query = self._get_book_participants(book_version) from booktype.apps.core.templatetags.booktype_tags import tag_username book_members_list = [tag_username(x) for x in members_query] # we should also get assigned users to other chapters assigned_users = book_version.chapter_set.all().values_list("assigned", flat=True) assigned_users = list(assigned_users) + book_members_list context['book_members'] = sorted(assigned_users) return context