def handle(self, *args, **options): """Synchronizes settings to journals. :param args: None :param options: None :return: None """ translation.activate('en') journals = journal_models.Journal.objects.all() journal_code = options.get('journal_code', None) if journal_code: try: journals = [journal_models.Journal.objects.get(code=journal_code)] except journal_models.Journal.DoesNotExist: journals = None print('No journal with that code was found.') if journals: print("Syncing to {0} Journals:".format(len(journals))) for journal in journals: install.update_settings(journal, management_command=True) print('Journal with ID {0} [{1}]: {2}. SETTINGS SYNCED.'.format(journal.id, journal.name, journal.domain)) install.update_license(journal, management_command=True)
def handle(self, *args, **options): """Installs Janeway :param args: None :param options: None :return: None """ call_command('makemigrations', 'sites') call_command('migrate') print("Please answer the following questions.\n") translation.activate('en') with transaction.atomic(): test_one = press_models.Press.objects.all() if not test_one: press = press_models.Press() press.name = input('Press name: ') press.domain = input('Press domain: ') press.main_contact = input('Press main contact (email): ') press.save() print("Thanks! We will now set up out first journal.\n") journal = journal_models.Journal() journal.code = input('Journal #1 code: ') journal.domain = input('Journal #1 domain: ') journal.save() print("Installing settings fixtures... ", end="") update_settings(journal, management_command=False) print("[okay]") print("Installing license fixtures... ", end="") update_license(journal, management_command=False) print("[okay]") print("Installing role fixtures") roles_path = os.path.join(settings.BASE_DIR, ROLES_RELATIVE_PATH) call_command('loaddata', roles_path) journal.name = input('Journal #1 name: ') journal.description = input('Journal #1 description: ') journal.save() journal.setup_directory() print("Thanks, Journal #1 has been saved.\n") call_command('show_configured_journals') call_command('sync_journals_to_sites') call_command('build_assets') print("Installing plugins.") call_command('install_plugins') print("Installing Cron jobs") try: call_command('install_cron') except FileNotFoundError: self.stderr.write("Error Installing cron") print('Create a super user.') call_command('createsuperuser') print( 'Open your browser to your new journal domain {domain}/install/ to continue this setup process.' .format(domain=journal.domain)) print(JANEWAY_ASCII)
def create_journal(): """ Creates a dummy journal for testing :return: a journal """ update_xsl_files() journal_one = journal_models.Journal(code="TST", domain="testserver") journal_one.title = "Test Journal: A journal of tests" journal_one.save() update_settings(journal_one, management_command=False) return journal_one
def make_test_journal(**kwargs): try: update_xsl_files() journal = Journal(**kwargs) journal.save() update_settings(journal, management_command=False) except IntegrityError: pass return journal
def handle(self, *args, **options): """Synchronizes settings to journals. :param args: None :param options: None :return: None """ translation.activate('en') journals = journal_models.Journal.objects.all() journal_code = options.get('journal_code', None) if journal_code: try: journals = [ journal_models.Journal.objects.get(code=journal_code) ] except journal_models.Journal.DoesNotExist: journals = None print('No journal with that code was found.') if journals: print("Syncing to {0} Journals:".format(len(journals))) for journal in journals: install.update_settings(journal, management_command=True) print( 'Journal with ID {0} [{1}]: {2}. SETTINGS SYNCED.'.format( journal.id, journal.name, journal.domain)) install.update_license(journal, management_command=True) if not journal_code: file = open( os.path.join(settings.BASE_DIR, 'utils', 'install', 'press_settings.json'), 'r') text = json.loads(file.read()) for setting in text: for press in press_models.Press.objects.all(): print("Syncing to {press}".format(press=press.name)) setting = press_models.PressSetting.objects.get_or_create( press=press, name=setting['name'], defaults={ 'value': setting['value'], 'is_boolean': setting['is_boolean'] })
def handle(self, *args, **options): """Synchronizes settings to journals. :param args: None :param options: None :return: None """ journals = journal_models.Journal.objects.all() print("Journals:") for journal in journals: install.update_settings(journal, management_command=True, overwrite_with_defaults=True) print('Journal with ID {0} [{1}]: {2}. SETTINGS SYNCED.'.format( journal.id, journal.name, journal.domain))
def handle(self, *args, **options): """Installs Janeway :param args: None :param options: None :return: None """ call_command('makemigrations') call_command('migrate') print("Please answer the following questions.\n") translation.activate('en') test_one = press_models.Press.objects.all() if not test_one: press = press_models.Press() press.name = input('Press name: ') press.domain = input('Press domain: ') press.main_contact = input('Press main contact (email): ') press.save() print("Thanks! We will now set up out first journal.\n") journal = journal_models.Journal() journal.code = input('Journal #1 code: ') journal.domain = input('Journal #1 domain: ') journal.save() install.update_settings(journal, management_command=True) install.update_license(journal, management_command=True) journal.name = input('Journal #1 name: ') journal.description = input('Journal #1 description: ') journal.save() print("Thanks, Journal #1 has been saved.\n") call_command('show_configured_journals') call_command('sync_journals_to_sites') call_command('build_assets') call_command('install_plugins') call_command('install_cron') call_command('loaddata', 'utils/install/roles.json') print('Create a super user.') call_command('createsuperuser') print( 'Open your browser to your domain /install/ to continue this setup process.' )
def install(): defaults = { 'version': VERSION, 'display_name': DISPLAY_NAME, 'enabled': True, } plugin, created = models.Plugin.objects.get_or_create( name=SHORT_NAME, defaults=defaults, ) update_settings(file_path='plugins/apc/install/settings.json') if created: print('Plugin {0} installed.'.format(PLUGIN_NAME)) else: if plugin.version != VERSION: plugin.version = VERSION plugin.save() print('Plugin {0} version updated.'.format(PLUGIN_NAME)) else: print('Plugin {0} is already installed.'.format(PLUGIN_NAME))
def install(): plugin, created = models.Plugin.objects.get_or_create(name=SHORT_NAME, defaults={ "enabled": True, "version": VERSION, "display_name": DISPLAY_NAME, }) if created: print('Plugin {0} installed.'.format(PLUGIN_NAME)) update_settings( file_path='plugins/doaj_transporter/install/settings.json') elif plugin.version != VERSION: print('Plugin updated: {0} -> {1}'.format(VERSION, plugin.version)) update_settings(file_path=JSON_SETTINGS_PATH) plugin.version = VERSION plugin.display_name = DISPLAY_NAME plugin.save() else: print('Plugin {0} is already installed.'.format(PLUGIN_NAME))
def install(): ArchivePlugin.install() update_settings(file_path='plugins/archive_plugin/install/settings.json', )
def handle(self, *args, **options): translation.activate('en') install.update_settings(management_command=True)
def setUp(self): press = helpers.create_press() self.journal, _ = helpers.create_journals() self.journal.save() call_command('load_default_settings', management_command=False) self.journal.publisher = "doaj" self.journal.code = "doaj" self.journal.save() install.update_license(self.journal, management_command=False) install.update_settings(self.journal, file_path=SETTINGS_PATH) self.article = self._create_article( date_published=datetime.date(day=1, month=7, year=2019)) self.encoded_article = """ { "admin": { "publisher_record_id": null }, "bibjson":{ "end_page": null, "identifier":[ { "id":"0000-0000", "type":"eissn" }, { "id": null, "type": "doi" } ], "author":[ { "name":"Testla Musketeer", "affiliation":"OLH", "orcid_id": null } ], "journal":{ "volume":"1", "license":[ { "title":"All rights reserved", "url":"https://creativecommons.org/licenses/authors", "open_access":true } ], "publisher":"doaj", "title":"Journal One", "number":"1", "language":[ "en" ] }, "keywords":[ ], "year": "2019", "month": "7", "start_page": null, "subject": null, "title":"The art of writing test titles", "link":[ { "url":"http://localhost/doaj/article/id/%s/", "content_type":"text/html", "type":"fulltext" } ], "abstract":"The test abstract" } } """ % (self.article.pk)
def install(): PandocPlugin.install() update_settings(file_path='plugins/pandoc_plugin/install/settings.json', )