Beispiel #1
0
    def test_01_get_journal(self, name, journal, journal_id, account, lock_journal, raises=None):

        if lock_journal:
            lock.lock("journal", journal.id, "someoneelse", blocking=True)

        svc = DOAJ.journalService()

        if journal is not None:
            journal.save(blocking=True)

        if raises is not None:
            with self.assertRaises(raises):
                if account is None:
                    retrieved, _ = svc.journal(journal_id)
                else:
                    retrieved, jlock = svc.journal(journal_id, lock_journal=True, lock_account=account)
        else:
            if account is None:
                retrieved, _ = svc.journal(journal_id)
                if retrieved is not None:
                    assert retrieved.data == journal.data
                else:
                    assert retrieved is None
            else:
                retrieved, jlock = svc.journal(journal_id, lock_journal=True, lock_account=account)
                if retrieved is not None:
                    assert retrieved.data == journal.data
                else:
                    assert retrieved is None

                time.sleep(2)

                assert lock.has_lock("journal", journal_id, account.id)
 def test_01_journal_2_application(self, name, journal, account, raises=None, comparator=None):
     svc = DOAJ.journalService()
     if raises is not None:
         with self.assertRaises(raises):
             svc.journal_2_application(journal, account)
     elif comparator is not None:
         application = svc.journal_2_application(journal, account)
         comparator(journal, application)
     else:
         assert False, "Specify either raises or comparator"
 def test_01_journal_2_application(self,
                                   name,
                                   journal,
                                   account,
                                   raises=None,
                                   comparator=None):
     svc = DOAJ.journalService()
     if raises is not None:
         with self.assertRaises(raises):
             svc.journal_2_application(journal, account)
     elif comparator is not None:
         application = svc.journal_2_application(journal, account)
         comparator(journal, application)
     else:
         assert False, "Specify either raises or comparator"
Beispiel #4
0
    def setUp(self):
        super(TestBLLJournalCSV, self).setUp()
        self.svc = DOAJ.journalService()

        self.store_tmp_dir = app.config["STORE_TMP_DIR"]
        app.config["STORE_TMP_DIR"] = os.path.join("test_store", "tmp")
        self.store_local_dir = app.config["STORE_LOCAL_DIR"]
        app.config["STORE_LOCAL_DIR"] = os.path.join("test_store", "main")

        self.localStore = store.StoreLocal(None)
        self.tmpStore = store.TempStore()
        self.container_id = app.config.get("STORE_CACHE_CONTAINER")
        self.store_tmp_impl = app.config["STORE_TMP_IMPL"]
        self.store_impl = app.config["STORE_IMPL"]

        self.cache = models.cache.Cache
        models.cache.Cache = ModelCacheMockFactory.in_memory()
        models.Cache = models.cache.Cache
Beispiel #5
0
    def setUp(self):
        super(TestBLLJournalCSV, self).setUp()
        self.svc = DOAJ.journalService()

        self.store_tmp_dir = app.config["STORE_TMP_DIR"]
        app.config["STORE_TMP_DIR"] = os.path.join("test_store", "tmp")
        self.store_local_dir = app.config["STORE_LOCAL_DIR"]
        app.config["STORE_LOCAL_DIR"] = os.path.join("test_store", "main")

        self.localStore = store.StoreLocal(None)
        self.tmpStore = store.TempStore()
        self.container_id = app.config.get("STORE_CACHE_CONTAINER")
        self.store_tmp_impl = app.config["STORE_TMP_IMPL"]
        self.store_impl = app.config["STORE_IMPL"]

        self.cache = models.cache.Cache
        models.cache.Cache = ModelCacheMockFactory.in_memory()
        models.Cache = models.cache.Cache
Beispiel #6
0
def update_request(journal_id):
    # DOAJ BLL for this request
    journalService = DOAJ.journalService()
    applicationService = DOAJ.applicationService()

    # if this is a delete request, deal with it first and separately from the below logic
    if request.method == "DELETE":
        journal, _ = journalService.journal(journal_id)
        application_id = journal.current_application
        if application_id is not None:
            applicationService.delete_application(
                application_id, current_user._get_current_object())
        else:
            abort(404)
        return ""

    # load the application either directly or by crosswalking the journal object
    application = None
    jlock = None
    alock = None
    try:
        application, jlock, alock = applicationService.update_request_for_journal(
            journal_id, account=current_user._get_current_object())
    except AuthoriseException as e:
        if e.reason == AuthoriseException.WRONG_STATUS:
            journal, _ = journalService.journal(journal_id)
            return render_template(
                "publisher/application_already_submitted.html",
                journal=journal)
        else:
            abort(404)
    except lock.Locked as e:
        journal, _ = journalService.journal(journal_id)
        return render_template("publisher/locked.html",
                               journal=journal,
                               lock=e.lock)

    # if we didn't find an application or journal, 404 the user
    if application is None:
        if jlock is not None: jlock.delete()
        if alock is not None: alock.delete()
        abort(404)

    # if we have a live application and cancel was hit, then cancel the operation and redirect
    # first determine if this is a cancel request on the form
    cancelled = request.values.get("cancel")
    if cancelled is not None:
        if jlock is not None: jlock.delete()
        if alock is not None: alock.delete()
        return redirect(url_for("publisher.updates_in_progress"))

    # if we are requesting the page with a GET, we just want to show the form
    if request.method == "GET":
        fc = formcontext.ApplicationFormFactory.get_form_context(
            role="publisher", source=application)
        return fc.render_template(edit_suggestion_page=True)

    # if we are requesting the page with a POST, we need to accept the data and handle it
    elif request.method == "POST":
        fc = formcontext.ApplicationFormFactory.get_form_context(
            role="publisher", form_data=request.form, source=application)
        if fc.validate():
            try:
                fc.finalise()
                Messages.flash(Messages.APPLICATION_UPDATE_SUBMITTED_FLASH)
                for a in fc.alert:
                    Messages.flash_with_url(a, "success")
                return redirect(url_for("publisher.updates_in_progress"))
            except formcontext.FormContextException as e:
                Messages.flash(e.message)
                return redirect(
                    url_for("publisher.update_request",
                            journal_id=journal_id,
                            _anchor='cannot_edit'))
            finally:
                if jlock is not None: jlock.delete()
                if alock is not None: alock.delete()
        else:
            return fc.render_template(edit_suggestion_page=True)