Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an Organization entity type with a Farm bundle #849

Draft
wants to merge 29 commits into
base: 3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a631df7
Initial organization entity type module.
mstenta May 15, 2024
7abe59b
Fix PHPCodesniffer errors.
mstenta May 15, 2024
eece848
Delete migrate source plugin.
mstenta May 15, 2024
b3f1e63
Remove unnecessary system module version constraints.
mstenta May 15, 2024
0aefdb7
Enable bundle plugins for the Organization entity type.
mstenta May 15, 2024
23cf780
Enforce entity reference integrity on organization reference fields.
mstenta May 15, 2024
3add9d7
Add base fields to organization entities: data, file, image, notes.
mstenta May 15, 2024
0a203e0
Initial Farm organization type.
mstenta May 15, 2024
6038333
Add support for organization reference fields in farm_field.factory.
mstenta May 15, 2024
a9a1a94
Add a farm reference field to assets and logs.
mstenta May 15, 2024
7bc9a87
Document organizations in the data model.
mstenta May 15, 2024
7552f4e
Document where to find example bundle declarations in farmOS.
mstenta May 29, 2024
70a3387
Add a "Users" base field to Organizations.
mstenta May 28, 2024
bc0bcd3
Remove Farm reference from logs.
mstenta May 28, 2024
ddbd530
Put farm reference field in Meta sidebar fieldset.
mstenta May 28, 2024
484161e
Put farm field display in second region.
mstenta May 28, 2024
9e51c57
Move organization primary tasks to secondary tasks and disable Drupal…
mstenta May 28, 2024
aeb9e97
Enable Gin content form on organization entities.
mstenta May 28, 2024
24e9a22
Add a View of Organizations under Setup menu.
mstenta May 28, 2024
53d0b66
Add organization status filter
paul121 Jul 11, 2024
031aa8f
Sort by organization name
paul121 Jul 11, 2024
a518bc1
Add organization action link
paul121 Jul 11, 2024
2827a9a
Add asset tab to farm organization page
paul121 Jul 11, 2024
342c0d4
Use FarmEntityViewsData to support additional field types in views
paul121 Jul 11, 2024
29bee45
Set owner of cloned organizations
paul121 Jul 11, 2024
a2f52c0
Remove roles from Views remember_roles config.
mstenta Jul 12, 2024
e582ba9
Add a description to the Organizations menu item.
mstenta Jul 12, 2024
8ff93b1
Change farm from a bundle field to a base field.
mstenta Jul 12, 2024
f669dcb
Add support for organization entity type in farm_role module.
mstenta Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a "Users" base field to Organizations.
  • Loading branch information
mstenta committed Nov 21, 2024
commit 70a3387c68ab540de9de5df4975741dc4dedec15
6 changes: 6 additions & 0 deletions docs/model/type/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Relationships that are common to all Organization types include:

- Images
- Files
- Users

#### Images

Expand All @@ -89,3 +90,8 @@ of the Organization.

Files can be attached to Organizations. This provides a place to put documents
such as Shapefiles, PDFs, CSVs, or other files associated with the Organization.

#### Users

Users can be assigned to Organizations. This provides a way to group users based
on the Organization(s) they are associated with.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ function farm_entity_fields_organization_base_fields() {
'view' => 10,
],
],
'user' => [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could remove the user field to leverage it from a Group integration instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question @pcambra! I've been thinking about it ever since it came up in conversation.

(For readers who may not be familiar with recent conversations, this is referring to ideas for a potential contrib farmOS module that uses the data types provided by this PR + the Drupal Group module to enable a "multi-tenant" farmOS instance with access control between groups/farms).

In the context of the multi-tenant farmOS module, there needs to be a way to link users to Groups (farms), so that access control can be applied to them. The Group module provides its own way of doing this.

However, as of right now the plan is for that to be a contrib module which extends core farmOS data model. So perhaps the question right now is: are there use-cases for linking users to farms outside of the multi-tentant access controlled context? If so, then we may need a user relationship in core as well.

In reviewing the forum discussion, I found this, which I had forgotten about:

Discussed on the farmOS dev call today (with @symbioquine @paul121 @Fosten):

  • We decided to wait on adding the “Users” field to Organization entities. There isn’t a direct use for it in the current PR, and we may want to consider putting an Organization reference field on the User records instead.

Since there is a use-case now (multi-tenant farmOS), perhaps we should discuss it together again. If there is any possibility that we will want a user relationship in the core data model, then we should add that now and the multi-tenant module should work around it IMO. Otherwise we may end up with multiple different implementations for the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied most of this to the forum topic: https://farmos.discourse.group/t/organization-level-data/2003/10

Let's discuss over there (and in a future dev call).

'type' => 'entity_reference',
'label' => t('Users'),
'target_type' => 'user',
'multiple' => TRUE,
'weight' => [
'form' => 100,
'view' => 100,
],
],
];
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function testHookEntityBaseFieldInfo() {
'file',
'image',
'notes',
'user',
];
foreach ($field_names as $field_name) {
$this->assertArrayHasKey($field_name, $fields, "The organization $field_name field exists.");
Expand Down