Commit 763d625e authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Proper with_embargo treatment in search.

parent c6f9017d
...@@ -130,7 +130,7 @@ class RepoCalcView extends React.Component { ...@@ -130,7 +130,7 @@ class RepoCalcView extends React.Component {
{calcData.crystal_system} {calcData.crystal_system}
</CalcQuantity> </CalcQuantity>
<CalcQuantity label='spacegroup' loading={loading}> <CalcQuantity label='spacegroup' loading={loading}>
{calcData.spacegroup} {calcData.spacegroup_symbol} ({calcData.spacegroup})
</CalcQuantity> </CalcQuantity>
</div> </div>
<div> <div>
......
...@@ -139,10 +139,9 @@ class RepoCalcsResource(Resource): ...@@ -139,10 +139,9 @@ class RepoCalcsResource(Resource):
abort(400, message='invalid pagination') abort(400, message='invalid pagination')
if owner == 'all': if owner == 'all':
if g.user is None: q = Q('term', published=True) & Q('term', with_embargo=False)
q = Q('term', published=True) if g.user is not None:
else: q = q | Q('term', owners__user_id=g.user.user_id)
q = Q('term', published=True) | Q('term', owners__user_id=g.user.user_id)
elif owner == 'user': elif owner == 'user':
if g.user is None: if g.user is None:
abort(401, message='Authentication required for owner value user.') abort(401, message='Authentication required for owner value user.')
......
...@@ -555,14 +555,17 @@ class TestRepo(UploadFilesBasedTests): ...@@ -555,14 +555,17 @@ class TestRepo(UploadFilesBasedTests):
calc_with_metadata = normalized.to_calc_with_metadata() calc_with_metadata = normalized.to_calc_with_metadata()
calc_with_metadata.update(calc_id='1', uploader=test_user.to_popo(), published=True) calc_with_metadata.update(calc_id='1', uploader=test_user.to_popo(), published=True, with_embargo=False)
search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True) search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True)
calc_with_metadata.update(calc_id='2', uploader=other_test_user.to_popo(), published=True) calc_with_metadata.update(calc_id='2', uploader=other_test_user.to_popo(), published=True, with_embargo=False)
calc_with_metadata.update(atoms=['Fe'], comment='this is a specific word', formula='AAA', basis_set='zzz') calc_with_metadata.update(atoms=['Fe'], comment='this is a specific word', formula='AAA', basis_set='zzz')
search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True) search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True)
calc_with_metadata.update(calc_id='3', uploader=other_test_user.to_popo(), published=False) calc_with_metadata.update(calc_id='3', uploader=other_test_user.to_popo(), published=False, with_embargo=False)
search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True)
calc_with_metadata.update(calc_id='4', uploader=other_test_user.to_popo(), published=True, with_embargo=True)
search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True) search.Entry.from_calc_with_metadata(calc_with_metadata).save(refresh=True)
@UploadFilesBasedTests.ignore_authorization @UploadFilesBasedTests.ignore_authorization
...@@ -578,8 +581,9 @@ class TestRepo(UploadFilesBasedTests): ...@@ -578,8 +581,9 @@ class TestRepo(UploadFilesBasedTests):
@pytest.mark.parametrize('calcs, owner, auth', [ @pytest.mark.parametrize('calcs, owner, auth', [
(2, 'all', 'none'), (2, 'all', 'none'),
(2, 'all', 'test_user'), (2, 'all', 'test_user'),
(4, 'all', 'other_test_user'),
(1, 'user', 'test_user'), (1, 'user', 'test_user'),
(2, 'user', 'other_test_user'), (3, 'user', 'other_test_user'),
(0, 'staging', 'test_user'), (0, 'staging', 'test_user'),
(1, 'staging', 'other_test_user') (1, 'staging', 'other_test_user')
]) ])
......
...@@ -17,6 +17,7 @@ import random ...@@ -17,6 +17,7 @@ import random
from essential_generators import DocumentGenerator from essential_generators import DocumentGenerator
import datetime import datetime
from ase.data import chemical_symbols from ase.data import chemical_symbols
from ase.spacegroup import Spacegroup
from nomad import datamodel, parsing, utils, files from nomad import datamodel, parsing, utils, files
...@@ -89,7 +90,9 @@ def generate_calc(pid: int = 0, calc_id: str = None, upload_id: str = None) -> d ...@@ -89,7 +90,9 @@ def generate_calc(pid: int = 0, calc_id: str = None, upload_id: str = None) -> d
self.xc_functional = random.choice(xc_functionals) self.xc_functional = random.choice(xc_functionals)
self.system = random.choice(systems) self.system = random.choice(systems)
self.crystal_system = random.choice(crystal_systems) self.crystal_system = random.choice(crystal_systems)
self.spacegroup = '1' spacegroup = random.randint(1, 225)
self.spacegroup = str(spacegroup)
self.spacegroup_symbol = Spacegroup(spacegroup).symbol
self.code_name = random.choice(codes) self.code_name = random.choice(codes)
self.code_version = '1.0.0' self.code_version = '1.0.0'
......
Supports Markdown
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