girder-jsonforms 2.1.4__tar.gz → 2.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/PKG-INFO +2 -4
  2. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/README.md +1 -1
  3. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/doc/file-uploads.md +2 -8
  4. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/__init__.py +27 -36
  5. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/mail.py +21 -1
  6. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/models/entry.py +1 -31
  7. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/models/form.py +0 -7
  8. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/models/project.py +12 -0
  9. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/rest/form.py +0 -17
  10. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/scripts/preview_mail.py +7 -1
  11. girder_jsonforms-2.1.6/girder_jsonforms/scripts/send_review_notice.py +169 -0
  12. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/settings.py +0 -21
  13. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/web_client/dist/girder-plugin-jsonforms.umd.cjs +5 -5
  14. girder_jsonforms-2.1.6/girder_jsonforms/web_client/dist/style.css +2 -0
  15. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms.egg-info/PKG-INFO +2 -4
  16. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms.egg-info/SOURCES.txt +1 -1
  17. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms.egg-info/requires.txt +0 -2
  18. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/pyproject.toml +4 -3
  19. girder_jsonforms-2.1.4/girder_jsonforms/lib/google_drive.py +0 -157
  20. girder_jsonforms-2.1.4/girder_jsonforms/web_client/dist/style.css +0 -2
  21. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/LICENSE +0 -0
  22. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/doc/preload.md +0 -0
  23. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/asgi.py +0 -0
  24. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/__init__.py +0 -0
  25. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/announcement.py +0 -0
  26. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/events.py +0 -0
  27. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/igsn_client.py +0 -0
  28. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/igsn_vocab.py +0 -0
  29. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/jq.py +0 -0
  30. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/locks.py +0 -0
  31. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/metadata_dates.py +0 -0
  32. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/orcid.py +0 -0
  33. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/project_helpers.py +0 -0
  34. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/project_tasks.py +0 -0
  35. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/response_cache.py +0 -0
  36. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/lib/timing.py +0 -0
  37. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_assets/caimee-shield-80.png +0 -0
  38. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/_projectsFooter.mako +0 -0
  39. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/_projectsFooter.txt.mako +0 -0
  40. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/_projectsHeader.mako +0 -0
  41. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/projectDecision.mako +0 -0
  42. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/projectDecision.txt.mako +0 -0
  43. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/projectSubmitted.mako +0 -0
  44. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/mail_templates/projectSubmitted.txt.mako +0 -0
  45. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/models/__init__.py +0 -0
  46. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/models/deposition.py +0 -0
  47. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/rest/__init__.py +0 -0
  48. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/rest/aimdl.py +0 -0
  49. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/rest/deposition.py +0 -0
  50. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/rest/entry.py +0 -0
  51. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/rest/project.py +0 -0
  52. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/schemas/__init__.py +0 -0
  53. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/schemas/datacite-v4.5.json +0 -0
  54. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/scripts/__init__.py +0 -0
  55. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/scripts/migrate_metadata_dates.py +0 -0
  56. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/scripts/reconcile_igsn.py +0 -0
  57. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/__init__.py +0 -0
  58. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/amdee.py +0 -0
  59. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/folder_ops.py +0 -0
  60. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/handle_enumsource.py +0 -0
  61. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/htmax.py +0 -0
  62. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/igsn_registry.py +0 -0
  63. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/orcid.py +0 -0
  64. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/projects.py +0 -0
  65. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/pull_related_ids.py +0 -0
  66. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms/worker_plugin/relate_entry_to_igsn.py +0 -0
  67. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms.egg-info/dependency_links.txt +0 -0
  68. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms.egg-info/entry_points.txt +0 -0
  69. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/girder_jsonforms.egg-info/top_level.txt +0 -0
  70. {girder_jsonforms-2.1.4 → girder_jsonforms-2.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: girder-jsonforms
3
- Version: 2.1.4
3
+ Version: 2.1.6
4
4
  Summary: Girder plugin adding forms based on JSON-editor
5
5
  License-Expression: BSD-3-Clause
6
6
  Classifier: Development Status :: 4 - Beta
@@ -17,8 +17,6 @@ Requires-Dist: girder-wholetale>=2.0.13
17
17
  Requires-Dist: girder-jobs>=5.0.18
18
18
  Requires-Dist: girder-sample-tracker>=2.0.0
19
19
  Requires-Dist: girder-oauth>=5.0.18
20
- Requires-Dist: google-api-python-client
21
- Requires-Dist: google-auth-oauthlib
22
20
  Requires-Dist: jsondiff
23
21
  Requires-Dist: pandas
24
22
  Requires-Dist: openpyxl
@@ -30,4 +28,4 @@ This plugin provides a JSON Forms support for Girder. It is based on the [json-e
30
28
 
31
29
  ## Usage
32
30
 
33
- The plugin extends girder with two models: `Form` and `FormEntry` (with REST routes `/form` and `/entry` respectively). The `Form` model is used to define the form schema and the `FormEntry` model is used to store the form data. `FormEntries` are primarily kept in girder's mongo database, but can also be stored as JSON dumps in girder hierarchy and/or in Google Drive. The plugin provides a REST API to create, update, delete and retrieve forms and form entries. The plugin also provides a web UI component to fill and view form entries. Form schema is expected to have a single unique key field, which is used to identify the form entry (`uniqueField` key on a Form).
31
+ The plugin extends girder with two models: `Form` and `FormEntry` (with REST routes `/form` and `/entry` respectively). The `Form` model is used to define the form schema and the `FormEntry` model is used to store the form data. `FormEntries` are primarily kept in girder's mongo database, but can also be stored as JSON dumps in girder hierarchy. The plugin provides a REST API to create, update, delete and retrieve forms and form entries. The plugin also provides a web UI component to fill and view form entries. Form schema is expected to have a single unique key field, which is used to identify the form entry (`uniqueField` key on a Form).
@@ -4,4 +4,4 @@ This plugin provides a JSON Forms support for Girder. It is based on the [json-e
4
4
 
5
5
  ## Usage
6
6
 
7
- The plugin extends girder with two models: `Form` and `FormEntry` (with REST routes `/form` and `/entry` respectively). The `Form` model is used to define the form schema and the `FormEntry` model is used to store the form data. `FormEntries` are primarily kept in girder's mongo database, but can also be stored as JSON dumps in girder hierarchy and/or in Google Drive. The plugin provides a REST API to create, update, delete and retrieve forms and form entries. The plugin also provides a web UI component to fill and view form entries. Form schema is expected to have a single unique key field, which is used to identify the form entry (`uniqueField` key on a Form).
7
+ The plugin extends girder with two models: `Form` and `FormEntry` (with REST routes `/form` and `/entry` respectively). The `Form` model is used to define the form schema and the `FormEntry` model is used to store the form data. `FormEntries` are primarily kept in girder's mongo database, but can also be stored as JSON dumps in girder hierarchy. The plugin provides a REST API to create, update, delete and retrieve forms and form entries. The plugin also provides a web UI component to fill and view form entries. Form schema is expected to have a single unique key field, which is used to identify the form entry (`uniqueField` key on a Form).
@@ -118,7 +118,6 @@ var reference = {
118
118
  formField: field
119
119
  };
120
120
  if (value.targetPath) { reference.targetPath = value.targetPath; }
121
- if (this.model.get('gdriveFolderId')) { reference.gdriveFolderId = ...; }
122
121
  ```
123
122
 
124
123
  The reference is serialized into `otherParams.reference` and travels with the
@@ -130,7 +129,6 @@ upload to the server. Key fields:
130
129
  | `formField` | The dotted path of the `file` field (used by batch numbering). |
131
130
  | `targetPath` | The value of `targetPath` **at upload time** (see §6 caveat). |
132
131
  | `<uniqueField>` | The entry's unique id (e.g. `sampleId`). |
133
- | `gdriveFolderId` | Optional Google Drive target. |
134
132
 
135
133
  On `g:uploadFinished` the returned file ids are appended to the `file` field via
136
134
  `setField` (`EditFormView.js:271`), so the form value now records which files
@@ -266,15 +264,11 @@ metadata even though `targetPath` itself is now resolved from form data: batch
266
264
  numbering keys off `formField`, and the number is layered on top of the resolved
267
265
  base path.
268
266
 
269
- ## 8. Serialization and Google Drive
267
+ ## 8. Serialization
270
268
 
271
269
  If the form has `serialize: true`, `handle_serialization` (`models/entry.py:284`)
272
270
  dumps the entry itself as a JSON file into each resolved destination folder,
273
- reusing the same `targetPath` / `get_destination_folder` machinery. When a
274
- `gdriveFolderId` is configured, both moved files and the serialized entry are
275
- pushed to Google Drive via the `gdrive.upload` event, using
276
- `os.path.join(path, file_name)` as the Drive-side path — again built from the
277
- resolved `path`.
271
+ reusing the same `targetPath` / `get_destination_folder` machinery.
278
272
 
279
273
  ## 9. Lifecycle summary
280
274
 
@@ -2,6 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
  import json
4
4
  import logging
5
+ import re
5
6
  from pathlib import Path
6
7
 
7
8
  import cherrypy
@@ -13,7 +14,6 @@ from girder.api.describe import Description, autoDescribeRoute
13
14
  from girder.constants import AccessType, TokenScope, registerAccessFlag
14
15
  from girder.exceptions import GirderException, ValidationException
15
16
  from girder.models.collection import Collection
16
- from girder.models.file import File
17
17
  from girder.models.folder import Folder
18
18
  from girder.models.item import Item
19
19
  from girder.models.setting import Setting
@@ -22,7 +22,6 @@ from girder.plugin import GirderPlugin, registerPluginStaticContent
22
22
  from girder.utility import mail_utils, search
23
23
  from girder.utility.model_importer import ModelImporter
24
24
 
25
- from .lib.google_drive import authenticate_gdrive, upload_file_to_gdrive
26
25
  from .lib.locks import distributed_lock
27
26
  from .lib.events import (
28
27
  ensure_group,
@@ -51,7 +50,6 @@ from .worker_plugin.folder_ops import (
51
50
  delete_folder_task,
52
51
  )
53
52
 
54
- GDRIVE_SERVICE = None
55
53
  logger = logging.getLogger(__name__)
56
54
 
57
55
 
@@ -99,35 +97,19 @@ def annotate_upload(event):
99
97
  Item().setMetadata(item, {"igsn": reference["igsn"], "type": reference["type"]})
100
98
 
101
99
 
102
- def upload_to_gdrive(event):
103
- global GDRIVE_SERVICE
104
- if GDRIVE_SERVICE is None:
105
- logger.error("Google Drive integration is not enabled.")
106
- return
107
- info = event.info
108
- file = info["file"]
109
-
110
- with File().open(file) as fh:
111
- gdrive_file_id = upload_file_to_gdrive(
112
- GDRIVE_SERVICE,
113
- info["gdriveFolderId"],
114
- info["path"],
115
- fh,
116
- mimetype=file["mimeType"],
117
- )
118
- parent = Item().load(
119
- file["itemId"], level=AccessType.WRITE, user=info["currentUser"]
120
- )
121
- Item().setMetadata(parent, {"gdriveFileId": gdrive_file_id})
122
-
123
-
124
100
  def igsn_search(query, types, user, level, limit, offset):
125
101
  results = {}
126
102
  allowed = {
127
103
  "folder": ["_id", "name", "description", "parentId", "meta.igsn"],
128
104
  "item": ["_id", "name", "description", "folderId", "meta.igsn"],
129
105
  }
130
- query = {"meta.igsn": {"$regex": query, "$options": "i"}}
106
+ # A prefix match ("all data associated with JHAMAA00001", children
107
+ # included). Anchored and case sensitive so it runs as a range scan on
108
+ # meta.igsn_1; the previous unanchored /i regex could not use an index and
109
+ # scanned every item (~570ms per page). IGSNs are uppercase (IGSN_REGEX),
110
+ # so uppercasing the query keeps it effectively case insensitive.
111
+ query = {"meta.igsn": {"$regex": "^" + re.escape(query.strip().upper())}}
112
+ sort = [("meta.igsn", 1), ("_id", 1)]
131
113
  for modelName in types:
132
114
  if modelName not in allowed:
133
115
  continue
@@ -135,7 +117,9 @@ def igsn_search(query, types, user, level, limit, offset):
135
117
  if model is None:
136
118
  continue
137
119
  if hasattr(model, "filterResultsByPermission"):
138
- cursor = model.find(query, fields=allowed[modelName] + ["public", "access"])
120
+ cursor = model.find(
121
+ query, fields=allowed[modelName] + ["public", "access"], sort=sort
122
+ )
139
123
  results[modelName] = [
140
124
  model.filter(obj, user)
141
125
  for obj in model.filterResultsByPermission(
@@ -144,7 +128,13 @@ def igsn_search(query, types, user, level, limit, offset):
144
128
  ]
145
129
  else:
146
130
  results[modelName] = list(
147
- model.find(query, fields=allowed[modelName], limit=limit, offset=offset)
131
+ model.find(
132
+ query,
133
+ fields=allowed[modelName],
134
+ limit=limit,
135
+ offset=offset,
136
+ sort=sort,
137
+ )
148
138
  )
149
139
  return results
150
140
 
@@ -425,6 +415,10 @@ def add_public_settings(event):
425
415
  settings["jsonforms.igsn_registry_enabled"] = bool(
426
416
  (Setting().get(PluginSettings.IGSN_SERVICE_URL) or "").strip()
427
417
  )
418
+ # Lets the web client show the Projects nav to reviewers, not only site
419
+ # admins: it checks this id against the current user's own ``groups``.
420
+ group = reviewers_group(create=False)
421
+ settings["jsonforms.reviewers_group_id"] = str(group["_id"]) if group else None
428
422
 
429
423
 
430
424
  class JSONFormsPlugin(GirderPlugin):
@@ -455,6 +449,11 @@ class JSONFormsPlugin(GirderPlugin):
455
449
  # it was the single largest remaining consumer of database time once
456
450
  # the AIMDL listing queries stopped dominating.
457
451
  Item().ensureIndices([([("copyOfItem", 1), ("projectId", 1)], {})])
452
+ # The "igsn" search mode (the deposition page's data listing) is an
453
+ # anchored prefix regex on meta.igsn; without these it was a full
454
+ # collection scan per page. aimdl's exact meta.igsn lookups benefit too.
455
+ Item().ensureIndices(["meta.igsn"])
456
+ Folder().ensureIndices(["meta.igsn"])
458
457
  Item().exposeFields(level=AccessType.READ, fields={"projectId"})
459
458
  ModelImporter.registerModel("deposition", DepositionModel, plugin="jsonforms")
460
459
  ModelImporter.registerModel("entry", FormEntryModel, plugin="jsonforms")
@@ -464,12 +463,6 @@ class JSONFormsPlugin(GirderPlugin):
464
463
  ModelImporter.registerModel(
465
464
  "prefixcounter", PrefixCounterModel, plugin="jsonforms"
466
465
  )
467
- global GDRIVE_SERVICE
468
- if Setting().get(PluginSettings.GOOGLE_DRIVE_ENABLED):
469
- try:
470
- GDRIVE_SERVICE = authenticate_gdrive()
471
- except ValueError:
472
- logger.exception("Failed to authenticate with Google Drive")
473
466
  info["apiRoot"].item.route("GET", ("query",), _item_advanced_search)
474
467
  info["apiRoot"].folder.route(
475
468
  "PUT", (":id", "assign_igsn"), _assign_igsn_to_folder
@@ -524,8 +517,6 @@ class JSONFormsPlugin(GirderPlugin):
524
517
  events.bind("project.samples_added", "jsonforms", process_add_samples)
525
518
  events.bind("project.samples_removed", "jsonforms", process_remove_samples)
526
519
 
527
- if GDRIVE_SERVICE is not None:
528
- events.bind("gdrive.upload", "jsonforms", upload_to_gdrive)
529
520
  try:
530
521
  search.addSearchMode("igsn", igsn_search)
531
522
  except GirderException:
@@ -73,6 +73,26 @@ def projects_url(project=None):
73
73
  return f"{base}/proposal/{project['_id']}"
74
74
 
75
75
 
76
+ def girder_project_url(project):
77
+ """URL of ``project``'s page in Girder's own web client.
78
+
79
+ Reviewers act on a proposal there (the approve/reject buttons live on that
80
+ page), so their notification links to it rather than to the proposals UI.
81
+ An explicitly stored ``core.email_host`` wins; otherwise ``girder.$DOMAIN``,
82
+ because the setting's default is derived from the current request's local
83
+ host, which behind a proxy is not the public one.
84
+ """
85
+ stored = Setting().findOne({"key": SettingKey.EMAIL_HOST})
86
+ domain = os.environ.get("DOMAIN", "")
87
+ if stored and stored.get("value"):
88
+ base = stored["value"]
89
+ elif domain:
90
+ base = f"https://girder.{domain}"
91
+ else:
92
+ base = Setting().get(SettingKey.EMAIL_HOST) or ""
93
+ return f"{base.rstrip('/')}/#project/{project['_id']}"
94
+
95
+
76
96
  def _emails(users):
77
97
  return sorted({user["email"] for user in users if user.get("email")})
78
98
 
@@ -243,7 +263,7 @@ def send_submitted_notification(project):
243
263
  logo = logo_attachment()
244
264
  params = {
245
265
  "project": project,
246
- "projectUrl": projects_url(project),
266
+ "projectUrl": girder_project_url(project),
247
267
  "submitter": _submitter_name(project),
248
268
  "logoUrl": f"cid:{LOGO_CID}" if logo else None,
249
269
  }
@@ -8,7 +8,6 @@ import re
8
8
  import bson
9
9
  import jsondiff
10
10
  import jsonschema
11
- from girder import events
12
11
  from girder.constants import AccessType
13
12
  from girder.exceptions import ValidationException
14
13
  from girder.models.folder import Folder
@@ -148,7 +147,6 @@ class Changeset(acl_mixin.AccessControlMixin, Model):
148
147
 
149
148
  class FormEntry(acl_mixin.AccessControlMixin, Model):
150
149
  def initialize(self):
151
- global GDRIVE_SERVICE
152
150
  self.name = "entry"
153
151
  # TODO: create indices for all pairs?
154
152
  # self.ensureIndices(["formId", "data.sampleId"])
@@ -312,7 +310,6 @@ class FormEntry(acl_mixin.AccessControlMixin, Model):
312
310
  )
313
311
  child = self.unique(child, target)
314
312
  Folder().move(child, target, "folder")
315
- # TODO upload to GDrive
316
313
  entry["folders"].append(child["_id"])
317
314
  dirty = True
318
315
 
@@ -331,19 +328,6 @@ class FormEntry(acl_mixin.AccessControlMixin, Model):
331
328
  )
332
329
  child = self.unique(child, target)
333
330
  child = Item().move(child, target)
334
- for file in Item().childFiles(child):
335
- # Upload to GDrive
336
- gdrive_folder_id = child.get("meta", {}).get("gdriveFolderId")
337
- if gdrive_folder_id:
338
- events.trigger(
339
- "gdrive.upload",
340
- {
341
- "file": file,
342
- "gdriveFolderId": gdrive_folder_id,
343
- "path": os.path.join(path, file["name"]),
344
- "currentUser": creator,
345
- },
346
- )
347
331
  entry["files"].append(child["_id"])
348
332
  dirty = True
349
333
  Folder().remove(source)
@@ -376,25 +360,13 @@ class FormEntry(acl_mixin.AccessControlMixin, Model):
376
360
  reference = {
377
361
  f"{unique_field}": uniqueId,
378
362
  "targetPath": path,
379
- "gdriveFolderId": form.get("gdriveFolderId"),
380
363
  }
381
364
  size = f.getbuffer().nbytes
382
365
  upload = self._get_upload_for_entry(
383
366
  form["entryFileName"], target, creator, size, reference
384
367
  )
385
368
  # not really chunking here as JSON is small
386
- upload = Upload().handleChunk(upload, RequestBodyStream(f, size))
387
- if form.get("gdriveFolderId"):
388
- events.trigger(
389
- "gdrive.upload",
390
- {
391
- "file": upload,
392
- "gdriveFolderId": form["gdriveFolderId"],
393
- "gdriveFileId": reference.get("gdriveFileId"),
394
- "path": os.path.join(path, upload["name"]),
395
- "currentUser": creator,
396
- },
397
- )
369
+ Upload().handleChunk(upload, RequestBodyStream(f, size))
398
370
  processed.add(target["_id"])
399
371
 
400
372
  return self.save(entry, creator=creator)
@@ -403,8 +375,6 @@ class FormEntry(acl_mixin.AccessControlMixin, Model):
403
375
  def _get_upload_for_entry(fname, target, creator, size, reference):
404
376
  if existing_item := Item().findOne({"name": fname, "folderId": target["_id"]}):
405
377
  file = Item().childFiles(existing_item)[0]
406
- if "gdriveFileId" in existing_item.get("meta", {}):
407
- reference["gdriveFileId"] = existing_item["meta"]["gdriveFileId"]
408
378
  reference["itemId"] = existing_item["_id"]
409
379
  serialized_reference = json.dumps(
410
380
  reference, sort_keys=True, allow_nan=False, cls=JsonEncoder
@@ -35,7 +35,6 @@ class Form(AccessControlledModel):
35
35
  "jsHelpers",
36
36
  "created",
37
37
  "updated",
38
- "gdriveFolderId",
39
38
  "folderId",
40
39
  "serialize",
41
40
  "pathTemplate",
@@ -66,7 +65,6 @@ class Form(AccessControlledModel):
66
65
  folder=None,
67
66
  pathTemplate=None,
68
67
  entryFileName=None,
69
- gdriveFolderId=None,
70
68
  serialize=False,
71
69
  uniqueField=None,
72
70
  postEntryTask=None,
@@ -79,7 +77,6 @@ class Form(AccessControlledModel):
79
77
  "schema": schema,
80
78
  "jsHelpers": jsHelpers,
81
79
  "folderId": None,
82
- "gdriveFolderId": gdriveFolderId,
83
80
  "pathTemplate": pathTemplate,
84
81
  "postEntryTask": postEntryTask,
85
82
  "entryFileName": entryFileName or "entry.json",
@@ -106,7 +103,6 @@ class Form(AccessControlledModel):
106
103
  jsHelpers=None,
107
104
  pathTemplate=None,
108
105
  entryFileName=None,
109
- gdriveFolderId=None,
110
106
  serialize=None,
111
107
  uniqueField=None,
112
108
  ):
@@ -129,9 +125,6 @@ class Form(AccessControlledModel):
129
125
  if jsHelpers:
130
126
  form["jsHelpers"] = jsHelpers
131
127
 
132
- if gdriveFolderId:
133
- form["gdriveFolderId"] = gdriveFolderId
134
-
135
128
  if serialize is not None:
136
129
  form["serialize"] = serialize
137
130
 
@@ -356,6 +356,18 @@ class Project(AccessControlledModel):
356
356
  ) from ve
357
357
  return doc
358
358
 
359
+ def filter(self, doc, user, additionalKeys=None):
360
+ filtered = super().filter(doc, user, additionalKeys=additionalKeys)
361
+ if filtered is not None:
362
+ # Mirrors the check in rest/project.py:update_project, so the client can
363
+ # offer approve/reject to reviewers, not only to site admins.
364
+ filtered["_canReview"] = filtered[
365
+ "_accessLevel"
366
+ ] >= AccessType.WRITE and self.hasAccessFlags(
367
+ doc, user=user, flags="jsonforms.review_projects"
368
+ )
369
+ return filtered
370
+
359
371
  @property
360
372
  def project_collection(self):
361
373
  if self._project_collection is None:
@@ -198,12 +198,6 @@ class Form(Resource):
198
198
  required=False,
199
199
  dataType="string",
200
200
  )
201
- .param(
202
- "gdriveFolderId",
203
- "Google Drive folder ID to save the form entry",
204
- required=False,
205
- dataType="string",
206
- )
207
201
  .param(
208
202
  "serialize",
209
203
  "Store the form schema as a serialized JSON string",
@@ -240,7 +234,6 @@ class Form(Resource):
240
234
  folder,
241
235
  pathTemplate,
242
236
  entryFileName,
243
- gdriveFolderId,
244
237
  serialize,
245
238
  uniqueField,
246
239
  postEntryTask,
@@ -258,7 +251,6 @@ class Form(Resource):
258
251
  folder=folder,
259
252
  pathTemplate=pathTemplate,
260
253
  entryFileName=entryFileName,
261
- gdriveFolderId=gdriveFolderId or None,
262
254
  serialize=serialize,
263
255
  uniqueField=uniqueField,
264
256
  jsHelpers=jsHelpers,
@@ -298,12 +290,6 @@ class Form(Resource):
298
290
  required=False,
299
291
  dataType="string",
300
292
  )
301
- .param(
302
- "gdriveFolderId",
303
- "Google Drive folder ID to save the form entry",
304
- required=False,
305
- dataType="string",
306
- )
307
293
  .param(
308
294
  "serialize",
309
295
  "Store the form schema as a serialized JSON string",
@@ -341,7 +327,6 @@ class Form(Resource):
341
327
  folder,
342
328
  pathTemplate,
343
329
  entryFileName,
344
- gdriveFolderId,
345
330
  serialize,
346
331
  uniqueField,
347
332
  postEntryTask,
@@ -362,8 +347,6 @@ class Form(Resource):
362
347
  form["pathTemplate"] = None
363
348
  else:
364
349
  form["pathTemplate"] = pathTemplate
365
- if gdriveFolderId:
366
- form["gdriveFolderId"] = gdriveFolderId
367
350
  if serialize is not None:
368
351
  form["serialize"] = serialize
369
352
  if uniqueField is not None:
@@ -200,7 +200,13 @@ def render(
200
200
  project["status"] = extra["status"]
201
201
  params = {
202
202
  "project": project,
203
- "projectUrl": f"{projects_base}/proposal/{project['_id']}",
203
+ # Reviewers are sent to Girder's own project page, as lib/mail.py does;
204
+ # the submitter and PIs to the proposals UI.
205
+ "projectUrl": (
206
+ f"{host}/#project/{project['_id']}"
207
+ if variant == "submitted"
208
+ else f"{projects_base}/proposal/{project['_id']}"
209
+ ),
204
210
  "brandName": brand_name,
205
211
  "host": host,
206
212
  "logoUrl": logo_url,
@@ -0,0 +1,169 @@
1
+ """Send the "proposal is waiting for review" email for one existing proposal.
2
+
3
+ Unlike ``preview_mail.py``, which renders the templates with sample data and
4
+ no Girder at all, this talks to the live instance: it loads the proposal out
5
+ of MongoDB, renders the same templates with the same parameters, and hands the
6
+ message to the same ``_sendmail`` event a status transition would, so the
7
+ result is byte-for-byte what ``lib/mail.py:send_submitted_notification``
8
+ sends. Only the recipient differs -- it is the address given on the command
9
+ line rather than the proposal's resolved reviewer set.
10
+
11
+ The point is to be runnable from a shell inside a production container, where
12
+ the plugin is installed but no Girder server is being served::
13
+
14
+ docker exec -it <girder-container> \\
15
+ girder-jsonforms-send-review-notice JHU250001 reviewer@example.edu
16
+
17
+ # or, without the console script on PATH:
18
+ python -m girder_jsonforms.scripts.send_review_notice JHU250001 you@example.edu
19
+
20
+ Nothing is written back: the proposal's status is left alone, so this can be
21
+ used to nudge a reviewer about a proposal that is already under review, or to
22
+ smoke-test SMTP from the container. Pass ``--dry-run`` to print the assembled
23
+ message instead of connecting to the SMTP server.
24
+
25
+ The database, SMTP server, From address and brand name all come from the
26
+ container's own Girder configuration (``GIRDER_MONGO_URI`` and the ``core.*``
27
+ settings), so no arguments beyond the proposal and the address are needed.
28
+ """
29
+
30
+ import argparse
31
+ import logging
32
+ import os
33
+ import sys
34
+
35
+ logger = logging.getLogger("girder_jsonforms.send_review_notice")
36
+
37
+
38
+ def find_project(identifier):
39
+ """Load a proposal by its ``projectId`` (e.g. ``JHU250001``) or Mongo id.
40
+
41
+ ``projectId`` is tried first and matched case-insensitively, since that is
42
+ the identifier that appears in the UI and in the subject line of the mail
43
+ being re-sent; a 24-character hex string is also accepted so an operator
44
+ can paste the ``_id`` out of a URL.
45
+ """
46
+ import re
47
+
48
+ from bson.objectid import ObjectId
49
+ from girder_jsonforms.models.project import Project
50
+
51
+ model = Project()
52
+ project = model.findOne(
53
+ {"projectId": {"$regex": f"^{re.escape(identifier)}$", "$options": "i"}}
54
+ )
55
+ if project is not None:
56
+ return project
57
+ if ObjectId.is_valid(identifier):
58
+ return model.load(ObjectId(identifier), force=True)
59
+ return None
60
+
61
+
62
+ def send_notice(project, recipients):
63
+ """Send ``project``'s "submitted for review" mail to ``recipients``.
64
+
65
+ ``lib.mail.send_submitted_notification`` resolves the reviewer set itself
66
+ and takes no override, so the resolver it calls is swapped out for the
67
+ duration of the call. Reimplementing the send instead would defeat the
68
+ point -- subject, templates, parameters and logo have to be identical to
69
+ an automatic send -- and adding an override parameter would not help: this
70
+ script is dropped into an *already deployed* container and has to work
71
+ against whatever version of the plugin is installed there, not against one
72
+ shipping alongside it. Nothing is written back; the proposal's ACL and
73
+ status are untouched.
74
+ """
75
+ from girder_jsonforms.lib import mail
76
+
77
+ resolver = mail.reviewer_emails
78
+ mail.reviewer_emails = lambda _project: list(recipients)
79
+ try:
80
+ mail.send_submitted_notification(project)
81
+ finally:
82
+ mail.reviewer_emails = resolver
83
+
84
+
85
+ def main(argv=None):
86
+ parser = argparse.ArgumentParser(
87
+ description=__doc__.splitlines()[0],
88
+ formatter_class=argparse.RawDescriptionHelpFormatter,
89
+ )
90
+ parser.add_argument(
91
+ "project",
92
+ metavar="PROJECT",
93
+ help="Proposal to notify about: its projectId (e.g. JHU250001) or _id.",
94
+ )
95
+ parser.add_argument(
96
+ "email",
97
+ metavar="EMAIL",
98
+ nargs="+",
99
+ help="Address to send to; repeatable, one message per address.",
100
+ )
101
+ parser.add_argument(
102
+ "--domain",
103
+ default=None,
104
+ help=(
105
+ "Override $DOMAIN, which is what the proposal link in the mail is "
106
+ "built from (https://girder.<domain>/#project/<id>, Girder's own "
107
+ "project page) unless core.email_host is set explicitly, which "
108
+ "then wins. Defaults to the container's own $DOMAIN. A container "
109
+ "running a plugin older than this script links to "
110
+ "https://projects.<domain>/proposal/<id> instead."
111
+ ),
112
+ )
113
+ parser.add_argument(
114
+ "--dry-run",
115
+ action="store_true",
116
+ help=(
117
+ "Print the assembled message instead of sending it. Uses core's "
118
+ "GIRDER_EMAIL_TO_CONSOLE path, so everything short of the SMTP "
119
+ "connection runs exactly as it would for a real send."
120
+ ),
121
+ )
122
+ parser.add_argument("-v", "--verbose", action="store_true", help="Debug logging.")
123
+ args = parser.parse_args(argv)
124
+
125
+ logging.basicConfig(
126
+ level=logging.DEBUG if args.verbose else logging.INFO,
127
+ format="%(levelname)s %(message)s",
128
+ )
129
+
130
+ if args.domain:
131
+ os.environ["DOMAIN"] = args.domain
132
+ if args.dry_run:
133
+ # Read by girder.utility.mail_utils._submitEmail, which prints the
134
+ # message instead of opening an SMTP connection.
135
+ os.environ["GIRDER_EMAIL_TO_CONSOLE"] = "1"
136
+
137
+ # Imported here so --help works without a configured Girder or database.
138
+ from pathlib import Path
139
+
140
+ from girder.utility import mail_utils
141
+
142
+ import girder_jsonforms
143
+
144
+ # The Mako lookup normally gets this directory from JSONFormsPlugin.load,
145
+ # which has not run: no server is being started here. Appended rather than
146
+ # prepended for the same reason the plugin appends it -- the lookup is
147
+ # process-global and a prepended directory shadows core's templates.
148
+ mail_utils.addTemplateDirectory(
149
+ str(Path(girder_jsonforms.__file__).parent / "mail_templates")
150
+ )
151
+
152
+ project = find_project(args.project)
153
+ if project is None:
154
+ parser.error(f"No proposal matching {args.project!r}")
155
+
156
+ logger.info(
157
+ "Proposal %s (%s), status %r -> %s",
158
+ project.get("projectId"),
159
+ project["_id"],
160
+ project.get("status"),
161
+ ", ".join(args.email),
162
+ )
163
+ send_notice(project, args.email)
164
+ logger.info("Done.")
165
+ return 0
166
+
167
+
168
+ if __name__ == "__main__":
169
+ sys.exit(main())
@@ -14,7 +14,6 @@ IGSN_REGEX = re.compile(r"^[A-Z]{6}[0-9]{5}[A-Z0-9\-]*$", re.IGNORECASE)
14
14
  class PluginSettings:
15
15
  IGSN_INSTITUTIONS = "jsonforms.igsn_institutions"
16
16
  IGSN_MATERIALS = "jsonforms.igsn_materials"
17
- GOOGLE_DRIVE_ENABLED = "jsonforms.google_drive_enabled"
18
17
  IGSN_PUBLISHER = "jsonforms.igsn_publisher"
19
18
  IGSN_CLIENT_ID = "jsonforms.igsn_client_id"
20
19
  IGSN_PROVIDER_ID = "jsonforms.igsn_provider_id"
@@ -403,14 +402,6 @@ def validate_igsn_materials(doc):
403
402
  )
404
403
 
405
404
 
406
- @setting_utilities.default(PluginSettings.GOOGLE_DRIVE_ENABLED)
407
- def default_google_drive_enabled():
408
- """
409
- Default setting for enabling Google Drive integration.
410
- """
411
- return False
412
-
413
-
414
405
  @setting_utilities.default(PluginSettings.AIMDL_COUNTS)
415
406
  def default_aimdl_counts():
416
407
  """
@@ -419,18 +410,6 @@ def default_aimdl_counts():
419
410
  return False
420
411
 
421
412
 
422
- @setting_utilities.validator(PluginSettings.GOOGLE_DRIVE_ENABLED)
423
- def validate_google_drive_enabled(doc):
424
- """
425
- Validate the Google Drive integration setting.
426
- """
427
- if not isinstance(doc["value"], bool):
428
- raise ValidationException(
429
- "Google Drive integration must be a boolean.",
430
- "value",
431
- )
432
-
433
-
434
413
  @setting_utilities.validator(PluginSettings.AIMDL_CACHE_TTL)
435
414
  def validate_aimdl_cache_ttl(doc):
436
415
  value = doc["value"]