def handle(self, *args, **options): """ Create a new journal on this Janeway install. :param args: None :param options: Dictionary containing keys '--journal_name', '--journal_code' and '--base_url'. If any of these are not provided, they will be requested via raw_input. --delete can be provided to find and delete the journal if it already exists. :return: None """ translation.activate('en') delete = True if options.get('delete') else False journal_name = options.get('journal_name') if options.get('journal_name') else input( 'Enter the full name of the Journal: ') journal_code = options.get('journal_code') if options.get('journal_code') else input( 'Enter a short name for the Journal: ') base_url = options.get('base_url') if options.get('base_url') else input( 'Enter a base url for the Journal: ') if journal_name and journal_code and base_url: print('Creating new journal {0} ({1}) with domain {2}.'.format(journal_name, journal_code, base_url)) install.journal(name=journal_name, code=journal_code, base_url=base_url, delete=delete) if not delete: journal = journal_models.Journal.objects.get(code=journal_code) install.update_license(journal, management_command=False) call_command('show_configured_journals')
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 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): """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 manager_index(request): """ This is an over-ride view that is returned by core_manager_index when there is no journal. :param request: django request :return: contextualised template """ form = journal_forms.JournalForm() modal = None version = get_janeway_version() if request.POST: form = journal_forms.JournalForm(request.POST) modal = 'new_journal' if form.is_valid(): new_journal = form.save(request=request) new_journal.sequence = request.press.next_journal_order() new_journal.save() call_command('install_plugins') install.update_license(new_journal) install.update_issue_types(new_journal) new_journal.setup_directory() return redirect("{0}?journal={1}".format( reverse('core_edit_settings_group', kwargs={'group': 'journal'}), new_journal.pk)) template = 'press/press_manager_index.html' context = { 'journals': journal_models.Journal.objects.all().order_by('sequence'), 'form': form, 'modal': modal, 'published_articles': submission_models.Article.objects.filter( stage=submission_models.STAGE_PUBLISHED).select_related('journal') [:50], 'version': version, } return render(request, template, context)
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)