Skip to content

Commit

Permalink
Libraries: Form Validation
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Weber <[email protected]>
Signed-off-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr and rerowep committed Dec 13, 2018
1 parent 454252d commit a98039f
Show file tree
Hide file tree
Showing 49 changed files with 2,705 additions and 2,106 deletions.
2 changes: 1 addition & 1 deletion data/circulation_transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
"requests": 2
}
}
]
]
44 changes: 43 additions & 1 deletion data/organisations-libraries-locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,48 @@
"is_open": false,
"times": []
}
],
"exception_dates": [
{
"title": "Vacances de No\u00ebl",
"is_open": false,
"start_date": "2018-12-22",
"end_date": "2019-01-06"
},
{
"title": "8 f\u00e9vrier apr\u00e8s-midi",
"is_open": false,
"start_date": "2019-02-08",
"times": [
{
"start_time": "12:00",
"end_time": "18:00"
}
]
},
{
"title": "Dimanche du livre",
"is_open": true,
"start_date": "2019-05-24T10:00:00.000Z",
"times": [
{
"start_time": "10:00",
"end_time": "16:00"
}
]
},
{
"title": "1er ao\u00fbt",
"is_open": false,
"start_date": "2019-08-01",
"repeat": {
"interval": 1,
"period": "yearly",
"data": [
8
]
}
}
]
},
{
Expand Down Expand Up @@ -319,4 +361,4 @@
"name": "R\u00e9seau des biblioth\u00e8ques du Canton d'Aoste",
"pid": "1"
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,4 @@
"default": false
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion rero_ils/modules/items/form_options/items/item-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@
}
]
}
]
]
2 changes: 1 addition & 1 deletion rero_ils/modules/items/jsonschemas/items/item-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
]
}
}
}
}
2 changes: 1 addition & 1 deletion rero_ils/modules/items/mappings/v6/items/item-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion rero_ils/modules/loans/jsonschemas/loans/loan-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@
"title": "The name of the explicit action that triggered the transition to current state"
}
}
}
}
3 changes: 1 addition & 2 deletions rero_ils/modules/loans/mappings/v6/loans/loan-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,4 @@
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"description": "Name of the pickup location."
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
}
}
}
}
}
16 changes: 10 additions & 6 deletions rero_ils/modules/patrons/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_patron_by_email(cls, email=None):
"""Get patron by email."""
uuid, pid_value = cls._get_uuid_pid_by_email(email)
if uuid:
return super(IlsRecord, cls).get_record(uuid)
return super(Patron, cls).get_record(uuid)
else:
return None

Expand All @@ -84,7 +84,7 @@ def get_patron_by_barcode(cls, barcode=None):
).source(includes='pid').execute().to_dict()
try:
result = result['hits']['hits'][0]
return super(IlsRecord, cls).get_record(result['_id'])
return super(Patron, cls).get_record(result['_id'])
except Exception:
return None

Expand Down Expand Up @@ -175,7 +175,7 @@ def get_one_pickup_location(self):

def dumps(self, **kwargs):
"""Return pure Python dictionary with record metadata."""
data = super(IlsRecord, self).dumps(**kwargs)
data = super(Patron, self).dumps(**kwargs)
data['roles'] = self.role_names
data['name'] = ', '.join((
data.get('last_name', ''),
Expand All @@ -186,6 +186,8 @@ def dumps(self, **kwargs):
if data.get('is_patron', False):
patron_type = PatronType.get_record_by_pid(data['patron_type_pid'])
data['patron_type'] = patron_type.get('name')
if (self.organisation):
data['organisation_pid'] = self.organisation.pid
return data

@property
Expand Down Expand Up @@ -216,9 +218,11 @@ def library(self):
@property
def organisation(self):
"""Get organisation."""
return OrganisationWithLibraries.get_organisation_by_libraryid(
self.library.id
)
if (self.library):
return OrganisationWithLibraries.get_organisation_by_libraryid(
self.library.id
)
return None

@property
def name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
"description": "Qualify this user as a staff library."
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
}
}
}
}
}
48 changes: 46 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,37 @@
from rero_ils.modules.items_types.api import ItemType
from rero_ils.modules.libraries_locations.api import LibraryWithLocations
from rero_ils.modules.locations.api import Location
from rero_ils.modules.organisations_libraries.api import \
OrganisationWithLibraries
from rero_ils.modules.patrons.api import Patron
from rero_ils.modules.patrons_types.api import PatronType

# TODO: get url dynamiclly
url_schema = 'http://ils.test.rero.ch/schema'


@pytest.yield_fixture()
def limited_organisation_record():
"""Simple organisation record."""
yield {
'$schema': url_schema + '/organisations/organisation-v0.0.1.json',
'pid': 'organisation_pid_1',
'name': 'MV Sion',
'address': 'address',
}


@pytest.yield_fixture()
def limited_organisation_record_2():
"""Simple organisation record."""
yield {
'$schema': url_schema + '/organisations/organisation-v0.0.1.json',
'pid': 'organisation_pid_2',
'name': 'MV Martigny',
'address': 'address',
}


@pytest.yield_fixture()
def limited_library_record():
"""Simple library record."""
Expand Down Expand Up @@ -222,6 +246,7 @@ def limited_item_type_record():
@pytest.yield_fixture()
def all_resources_limited(
db,
limited_organisation_record,
limited_library_record,
limited_location_record,
limited_item_record,
Expand Down Expand Up @@ -249,6 +274,15 @@ def all_resources_limited(
limited_location_record, dbcommit=True, reindex=True, delete_pid=False
)
library.add_location(location, dbcommit=True, reindex=True)

organisation = OrganisationWithLibraries.create(
limited_organisation_record,
dbcommit=True,
reindex=True,
delete_pid=False
)
organisation.add_library(library)

simonetta = Patron.create(
limited_patron_simonetta, dbcommit=True, reindex=True, delete_pid=False
)
Expand All @@ -263,7 +297,7 @@ def all_resources_limited(
doc.add_item(item, dbcommit=True, reindex=True)
item.dbcommit(reindex=True)
db.session.commit()
yield doc, item, library, location, simonetta, philippe
yield doc, item, organisation, library, location, simonetta, philippe


@pytest.yield_fixture()
Expand Down Expand Up @@ -450,6 +484,7 @@ def limited_item_type_record_2():
@pytest.yield_fixture()
def all_resources_limited_2(
db,
limited_organisation_record_2,
limited_library_record_2,
limited_location_record_2,
limited_item_record_2,
Expand Down Expand Up @@ -481,6 +516,15 @@ def all_resources_limited_2(
dbcommit=True, reindex=True, delete_pid=False
)
library.add_location(location, dbcommit=True, reindex=True)

organisation = OrganisationWithLibraries.create(
limited_organisation_record_2,
dbcommit=True,
reindex=True,
delete_pid=False
)
organisation.add_library(library)

simonetta = Patron.create(
limited_patron_simonetta_2,
dbcommit=True,
Expand All @@ -500,7 +544,7 @@ def all_resources_limited_2(
doc.add_item(item, dbcommit=True, reindex=True)
item.dbcommit(reindex=True)
db.session.commit()
yield doc, item, library, location, simonetta, philippe
yield doc, item, organisation, library, location, simonetta, philippe


@pytest.fixture(scope='module')
Expand Down
Loading

0 comments on commit a98039f

Please sign in to comment.