Technical docs
Views#
Django views.
PeerReviewView#
View for the reviewer role of the Open Peer Review process.
Bases: LoginRequiredMixin, View
A view handling the peer review of metadata. This view supports loading, parsing, sorting metadata, and handling GET and POST requests for peer review.
Source code in dataedit/views.py
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | |
get(request, schema, table, review_id=None)
#
Handle GET requests for peer review. Loads necessary data and renders the review template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HttpRequest
|
The incoming HTTP GET request. |
required |
schema
|
str
|
The schema of the table. |
required |
table
|
str
|
The name of the table. |
required |
review_id
|
int
|
The ID of the review. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
HttpResponse |
HttpResponse
|
Rendered HTML response. |
Source code in dataedit/views.py
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 | |
get_all_field_descriptions(json_schema, prefix='')
#
Collects the field title, descriptions, examples, and badge information for each field of the oemetadata from the JSON schema and prepares them for further processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_schema
|
dict
|
The JSON schema to extract field descriptions from. |
required |
prefix
|
str
|
The prefix for nested keys. Defaults to an empty string. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing field descriptions, examples, and other information. |
Source code in dataedit/views.py
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 | |
load_json(schema, table, review_id=None)
#
Load JSON metadata from the database. If the review_id is available then load the metadata form the peer review instance and not from the table. This avoids changes to the metadata that is or was reviewed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
str
|
The schema of the table. |
required |
table
|
str
|
The name of the table. |
required |
review_id
|
int
|
Id of a peer review in the django database |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Loaded oemetadata. |
Source code in dataedit/views.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | |
load_json_schema()
#
Load the JSON schema used for validating metadata.
Note
Update this method if a new oemetadata version is released.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
JSON schema. |
Source code in dataedit/views.py
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
parse_keys(val, old='')
#
Recursively parse keys from a nested dictionary or list and return them as a list of dictionaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
dict or list
|
The input dictionary or list to parse. |
required |
old
|
str
|
The prefix for nested keys. Defaults to an empty string. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of dictionaries, each containing 'field' and 'value' keys. |
Source code in dataedit/views.py
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | |
post(request, schema, table, review_id=None)
#
Handle POST requests for submitting reviews by the reviewer.
This method: - Creates (or saves) reviews in the PeerReview table. - Updates the review finished attribute in the dataedit.Tables table, indicating that the table can be moved from the model draft topic.
Missing parts: - once the opr is finished (all field reviews agreed on) - merge field review results to metadata on table - awarde a badge - is field filled in? - calculate the badge by comparing filled fields and the badges form metadata schema
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HttpRequest
|
The incoming HTTP POST request. |
required |
schema
|
str
|
The schema of the table. |
required |
table
|
str
|
The name of the table. |
required |
review_id
|
int
|
The ID of the review. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
HttpResponse |
HttpResponse
|
Rendered HTML response for the review. |
Raises:
| Type | Description |
|---|---|
JsonResponse
|
If any error occurs, a JsonResponse containing the |
Note
- There are some missing parts in this method. Once the review process is finished (all field reviews agreed on), it should merge field review results to metadata on the table and award a badge based on certain criteria.
- A notification should be sent to the user if he/she can't review tables for which he/she is the table holder (TODO).
- After a review is finished, the table's metadata is updated, and the table can be moved to a different schema or topic (TODO).
Source code in dataedit/views.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | |
sort_in_category(schema, table, oemetadata)
#
Group flattened OEMetadata v2 fields into thematic buckets and attach placeholders required by the review UI.
Each entry has six keys:
{
"field": "
Source code in dataedit/views.py
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 | |
PeerRreviewContributorView#
View for the contributor role of the Open Peer Review process.
Bases: TablePeerReviewView
A view handling the contributor's side of the peer review process. This view supports rendering the review template and handling GET and POST requests for contributor's review.
Source code in dataedit/views.py
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 | |
get(request, schema, table, review_id)
#
Handle GET requests for contributor's review. Loads necessary data and renders the contributor review template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HttpRequest
|
The incoming HTTP GET request. |
required |
schema
|
str
|
The schema of the table. |
required |
table
|
str
|
The name of the table. |
required |
review_id
|
int
|
The ID of the review. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
HttpResponse |
HttpResponse
|
Rendered HTML response for contributor review. |
Source code in dataedit/views.py
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 | |
post(request, schema, table, review_id)
#
Handle POST requests for contributor's review. Merges and updates the review data in the PeerReview table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HttpRequest
|
The incoming HTTP POST request. |
required |
schema
|
str
|
The schema of the table. |
required |
table
|
str
|
The name of the table. |
required |
review_id
|
int
|
The ID of the review. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
HttpResponse |
HttpResponse
|
Rendered HTML response for contributor review. |
Source code in dataedit/views.py
1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 | |
Helper Functions#
Separated functionality that can be imported in other modules. It contains several functions that help with recurring tasks in the peer review system.
Provide helper functionality for views to reduce code lines in views.py make the codebase more modular.
SPDX-FileCopyrightText: 2025 Christian Winger https://github.com/wingechr © Öko-Institut e.V. SPDX-FileCopyrightText: 2025 Daryna Barabanova https://github.com/Darynarli © Reiner Lemoine Institut SPDX-FileCopyrightText: 2025 Jonas Huber https://github.com/jh-RLI © Reiner Lemoine Institut SPDX-FileCopyrightText: 2025 Jonas Huber https://github.com/jh-RLI © Reiner Lemoine Institut SPDX-FileCopyrightText: 2025 Jonas Huber https://github.com/jh-RLI © Reiner Lemoine Institut SPDX-FileCopyrightText: 2025 user https://github.com/Darynarli © Reiner Lemoine Institut SPDX-License-Identifier: AGPL-3.0-or-later
add_tag(name, color)
#
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
max 40 character tag text |
required |
color
|
str
|
hexadecimal color code, eg #aaf0f0 |
required |
Source code in dataedit/helper.py
509 510 511 512 513 514 515 | |
change_requests(schema, table)
#
Loads the dataedit admin interface :param request: :return:
Source code in dataedit/helper.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |
delete_peer_review(review_id)
#
Remove Peer Review by review_id. Args: review_id (int): ID review.
Returns:
| Name | Type | Description |
|---|---|---|
JsonResponse |
JSON response about successful deletion or error. |
Source code in dataedit/helper.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
edit_tag(id, name, color)
#
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
tag id |
required |
name
|
str
|
max 40 character tag text |
required |
color
|
str
|
hexadecimal color code, eg #aaf0f0 |
required |
Raises: sqlalchemy.exc.IntegrityError if name is not ok
Source code in dataedit/helper.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
find_tables(topic_name=None, query_string=None, tag_ids=None)
#
find tables given search criteria
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic_name
|
str
|
only tables in this topic |
None
|
query_string
|
str
|
user search term |
None
|
tag_ids
|
list
|
list of tag ids |
None
|
Returns:
| Type | Description |
|---|---|
QuerySet[Table]
|
QuerySet of Table objetcs |
Source code in dataedit/helper.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
get_all_tags(schema_name=None, table_name=None)
#
Load all tags of a specific table :param schema: Name of a schema :param table: Name of a table :return:
Source code in dataedit/helper.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
get_column_description(schema, table)
#
Return list of column descriptions: [{ "name": str, "data_type": str, "is_nullable': bool, "is_pk": bool }]
Source code in dataedit/helper.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
get_review_for_key(key, review_data)
#
Retrieve the review for a specific key from the review data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key for which to retrieve the review. review_data (dict): The review data containing reviews for various keys. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
The new value associated with the specified key in the review data, or None if the key is not found. |
Source code in dataedit/helper.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
merge_field_reviews(current_json, new_json)
#
Merge reviews from contributors and reviewers into a single JSON object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_json
|
dict
|
The current JSON object containing reviewer's reviews. |
required |
new_json
|
dict
|
The new JSON object containing contributor's reviews. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The merged JSON object containing both contributor's and reviewer's reviews. |
Note
If the same key is present in both the contributor's and reviewer's reviews, the function will merge the field evaluations. Otherwise, it will create a new entry in the Review-Dict.
Source code in dataedit/helper.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
recursive_update(metadata, review_data)
#
Recursively updates metadata with new values from review_data, skipping or removing fields with status 'rejected'.
Args: metadata (dict): The original metadata dictionary to update. review_data (dict): The review data containing the new values for various keys.
Note: The function iterates through the review data and for each key updates the corresponding value in metadata if the new value is present and is not an empty string, and if the field status is not 'rejected'.
Source code in dataedit/helper.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
set_nested_value(metadata, keys, value)
#
Set a nested value in a dictionary given a sequence of keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
dict
|
The dictionary in which to set the value. |
required |
keys
|
list
|
A list of keys representing the path to the nested value. |
required |
value
|
Any
|
The value to set. |
required |
Note
The function navigates through the dictionary using the keys and sets the value at the position indicated by the last key in the list.
Source code in dataedit/helper.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
update_keywords_from_tags(table, schema)
#
synchronize keywords in metadata with tags
Source code in dataedit/helper.py
534 535 536 537 538 539 540 541 | |
Metadata Functions#
Provide functionality that is related to retrieving and updating the oemetadata resource from the database. The oemetadata is the object of a review.
Save Metadata to Database#
Save updated metadata for a specific table in the OEP database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
str
|
The name of the OEP schema. |
required |
table
|
str
|
The name of the table in the OEP schema. |
required |
updated_metadata
|
dict
|
The updated metadata dictionary. |
required |
Note
This function loads the table object from the database, updates its metadata field, and then saves the updated table object back to the database.
Source code in dataedit/metadata/__init__.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
Load Metadata from Database#
Load metadata for a specific table from the OEP database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
The name of the table in the OEP schema. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The loaded metadata dictionary. |
Note
The function currently loads metadata from the Table.oemetadata field. There is a consideration to change this function to use a different approach or keep the old functionality (TODO).
Source code in dataedit/metadata/__init__.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
Models#
Django models.
PeerReview#
The model of the Open Peer Review defines what data is stored in the django database about each existing review. Next to the review itself it stores additional data about the the reviewer and contributor user and more. It is used in the PeerReviewManger.
Note
This model also provides functionality that is directly related to the model. It is up to discussion if we want to keep the functionality inside the model.
Bases: Model
Represents a peer review in the database.
Attributes:
| Name | Type | Description |
|---|---|---|
table |
CharField
|
Name of the table being reviewed. |
reviewer |
ForeignKey
|
The user who reviews. |
contributor |
ForeignKey
|
The user who contributes. |
is_finished |
BooleanField
|
Whether the review is finished. |
date_started |
DateTimeField
|
When the review started. |
date_submitted |
DateTimeField
|
When the review was submitted. |
date_finished |
DateTimeField
|
When the review finished. |
review |
JSONField
|
The review data in JSON format. |
Source code in dataedit/models.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
delete(*args, **kwargs)
#
Custom delete method to remove related PeerReviewManager entries.
Source code in dataedit/models.py
474 475 476 477 478 479 480 481 | |
get_prev_and_next_reviews(table)
#
Sets the prev_review and next_review fields based on the date_started field of the PeerReview objects associated with the same table.
Source code in dataedit/models.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
load(table)
classmethod
#
Load the current reviewer user. The current review is review is determened by the latest date started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
string
|
Table name |
required |
Returns:
| Name | Type | Description |
|---|---|---|
opr |
PeerReview
|
PeerReview object related to the latest |
Union[PeerReview, None]
|
date started. |
Source code in dataedit/models.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
set_version_of_metadata_for_review(table, *args, **kwargs)
#
Once the peer review is started, we save the current version of the oemetadata that is present on the table to the peer review instance to be able to do the review to a fixed state of the metadata.
A started review means a reviewer saves / submits or finishes (in case the review is completed in one go) a review.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table name |
required |
Returns:
| Name | Type | Description |
|---|---|---|
State |
tuple
|
Bool value that indicates weather there is already |
|
a version of oemetadata available for this review & readable |
||
|
status message. |
Source code in dataedit/models.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
update(*args, **kwargs)
#
Update the peer review if the latest peer review is not finished yet but either saved or submitted.
Source code in dataedit/models.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
PeerReviewManager#
The Manager is introduced to be able to store additional information about the peer review process and separate it from the PeerReview model. The process is started by submitting a review and the manager maintains the order of which user has to take the next action to be able to hold and activate the process.
Note
This model also provides functionality that is directly related to the model. It is up to discussion if we want to keep the functionality inside the model.
Bases: Model
Manages peer review processes.
This model handles the 1:n relation between table and open peer reviews. It tracks the days open for the peer review and its state. It determines who is next in the process between reviewer and contributor. It provides information about the previous and next review. It offers several methods that provide generic filters for the peer reviews.
Attributes:
| Name | Type | Description |
|---|---|---|
opr |
ForeignKey
|
The associated peer review. |
current_reviewer |
CharField
|
The current reviewer. |
status |
CharField
|
The current status of the review. |
is_open_since |
CharField
|
How long the review has been open. |
prev_review |
ForeignKey
|
The previous review in the process. |
next_review |
ForeignKey
|
The next review in the process. |
Source code in dataedit/models.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | |
filter_latest_open_opr_by_contributor(contributor_user)
staticmethod
#
Get the last open peer review for the given contributor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contributor_user
|
User
|
The contributor user. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PeerReview |
Last open peer review or None if not found. |
Source code in dataedit/models.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | |
filter_latest_open_opr_by_reviewer(reviewer_user)
staticmethod
#
Get the last open peer review for the given contributor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contributor_user
|
User
|
The contributor user. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PeerReview |
Last open peer review or None if not found. |
Source code in dataedit/models.py
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | |
filter_opr_by_contributor(contributor_user)
staticmethod
#
Filter peer reviews by contributor, excluding those with current peer is reviewer and the data status "SAVED" in the peer review manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contributor_user
|
User
|
The contributor user. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QuerySet |
Filtered peer reviews. |
Source code in dataedit/models.py
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | |
filter_opr_by_reviewer(reviewer_user)
staticmethod
#
Filter peer reviews by reviewer, excluding those with current peer is contributor and the data status "SAVED" in the peer review manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reviewer_user
|
User
|
The reviewer user. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QuerySet |
Filtered peer reviews. |
Source code in dataedit/models.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | |
filter_opr_by_table(table)
staticmethod
#
Filter peer reviews by table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QuerySet |
QuerySet[PeerReview]
|
Filtered peer reviews. |
Source code in dataedit/models.py
828 829 830 831 832 833 834 835 836 837 838 839 | |
load(opr)
classmethod
#
Load the peer review manager associated with the given peer review.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opr
|
PeerReview
|
The peer review. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PeerReviewManager |
The peer review manager. |
Source code in dataedit/models.py
623 624 625 626 627 628 629 630 631 632 633 634 635 | |
load_contributor(table)
staticmethod
#
Get the contributor for the table a review is started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
User |
The contributor user. |
Source code in dataedit/models.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | |
load_reviewer(table)
staticmethod
#
Get the reviewer for the table a review is started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
User |
The reviewer user. |
Source code in dataedit/models.py
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | |
save(*args, **kwargs)
#
Override the save method to perform additional logic before saving the peer review manager.
Source code in dataedit/models.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | |
set_next_reviewer()
#
Set the order on which peer will be required to perform a action to continue with the process.
Source code in dataedit/models.py
676 677 678 679 680 681 682 683 684 685 686 | |
update_open_since(opr=None, *args, **kwargs)
classmethod
#
Update the "is_open_since" field of the peer review manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opr
|
PeerReview
|
The peer review. |
None
|
Source code in dataedit/models.py
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
whos_turn()
#
Get the user and role (contributor or reviewer) whose turn it is.
Returns:
| Type | Description |
|---|---|
|
Tuple[str, User]: The role and user. |
Source code in dataedit/models.py
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | |