Commit c143952a authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed edit api GUI and broken re_pack process. #530

parent 18fd644a
......@@ -787,7 +787,9 @@ class EditUserMetadataDialogUnstyled extends React.Component {
coauthors: [],
shared_with: [],
datasets: [],
with_embargo: 'lift'
with_embargo: {
value: 'lift'
}
}
this.unmounted = false
}
......@@ -983,11 +985,12 @@ class EditUserMetadataDialogUnstyled extends React.Component {
}
}
const metadataFieldProps = (key, verify) => ({
const metadataFieldProps = (key, verify, defaultValue) => ({
modified: Boolean(actions[key]),
defaultValue: defaultValue,
onChange: checked => {
if (checked) {
this.setState({actions: {...actions, [key]: editDataToActions(this.editData[key])}}, () => {
this.setState({actions: {...actions, [key]: editDataToActions(this.editData[key] || defaultValue)}}, () => {
if (verify) {
this.verify()
}
......@@ -1060,7 +1063,7 @@ class EditUserMetadataDialogUnstyled extends React.Component {
label="Datasets"
/>
</UserMetadataField>
<UserMetadataField classes={{container: classes.liftEmbargoLabel}} {...metadataFieldProps('with_embargo', true)}>
<UserMetadataField classes={{container: classes.liftEmbargoLabel}} {...metadataFieldProps('with_embargo', true, 'lift')}>
<FormLabel>Lift embargo</FormLabel>
</UserMetadataField>
</DialogContent>
......
......@@ -579,6 +579,7 @@ class EditRepoCalcsResource(Resource):
mongo_update = {}
uploader_ids = None
lift_embargo = False
has_error = False
removed_datasets = None
with utils.timer(common.logger, 'edit verified'):
......
......@@ -101,7 +101,7 @@ def __run_processing(
else:
upload.reset(force=True)
process(upload)
upload.block_until_complete(interval=.5)
upload.block_until_process_complete(interval=.5)
if upload.tasks_status == proc.FAILURE:
logger.info('%s with failure' % label, upload_id=upload.upload_id)
......
......@@ -360,11 +360,21 @@ class Proc(Document, metaclass=ProcMetaclass):
pass
def block_until_complete(self, interval=0.01):
'''
Reloads the process constantly until it sees a completed process with finished tasks.
Should be used with care as it can block indefinitely. Just intended for testing
purposes.
'''
while self.tasks_running or self.process_running:
time.sleep(interval)
self.reload()
def block_until_process_complete(self, interval=0.01):
'''
Reloads the process constantly until it sees a completed process. Should be
used with care as it can block indefinitely. Just intended for testing purposes.
'''
while self.tasks_running or self.process_running:
while self.process_running:
time.sleep(interval)
self.reload()
......
......@@ -1092,16 +1092,7 @@ class Upload(Proc):
def re_pack(self):
''' A *process* that repacks the raw and archive data based on the current embargo data. '''
assert self.published
# mock the steps of actual processing
self._continue_with('uploading')
self._continue_with('extracting')
self._continue_with('parse_all')
self._continue_with('cleanup')
self.upload_files.re_pack(self.user_metadata())
self.joined = True
self._complete()
@process
def process_upload(self):
......
......@@ -1747,7 +1747,7 @@ class TestEditRepo():
@pytest.mark.timeout(config.tests.default_timeout)
def test_edit_lift_embargo(api, published, other_test_user_auth):
def test_edit_lift_embargo(api, published, other_test_user_auth, no_warn):
example_calc = Calc.objects(upload_id=published.upload_id).first()
assert example_calc.metadata['with_embargo']
elastic_calc = next(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment