Skip to content

Private spaces implementation - #1339

Merged
fbacall merged 115 commits into
ElixirTeSS:masterfrom
valentinRyckaert:private-spaces-with-groups
Aug 6, 2026
Merged

Private spaces implementation#1339
fbacall merged 115 commits into
ElixirTeSS:masterfrom
valentinRyckaert:private-spaces-with-groups

Conversation

@valentinRyckaert

Copy link
Copy Markdown
Contributor

Summary of changes

Database

3 new tables

  • groups:
    • id: bigint
    • title: string
  • groups_membership:
    • user_id: bigint
    • group_id: bigint
    • owner: boolean
  • groups_spaces:
    • group_id: bigint
    • space_id: bigint

Changes in existing tables

  • spaces:
    • new - is_private: boolean

Code

New group controller and policy

  • everyone can see all groups (like users)
  • only members and admins of a group can see the group details page
  • only owners and admins can edit/destroy a group (and so add people)
  • only admins can create a group
  • cant create/edit/destroy by API

New MemberShip Model

  • primary key: group_id, user_id
  • belongs to user
  • belongs to group

Shown? in application policy

  • show if:
    • the record does not belong to a space
    • the space of the record is public
    • the record is a space (so the space list can be shown in the main space)
    • the space of the record is the current space and user is in at least one of the required groups for the space (the user needs to be connected) or the user is an admin (admin have so full rights)

Spaces controller and policy updates

  • space policy:

    • everyone can see public spaces
    • only members of required groups can see private spaces
    • only space admins/ main admins can edit space
    • only main admins can create/destroy space
  • space controller:

    • index: filter shown spaces with shown? policy function

Solr search_index updates

  • uses shown? to filter the ressources list to show (index view of materials, events and spaces)

Application controller updates

  • check if the user has the right to access current_space (private space) with the shown? function and show default space if not

Space model update

  • all ressources form a private space are destroyed if the space is destroyed
  • if the space is public, all the ressources except roles (destroyed) are nullified
  • when nullified, we reload Solr index to make changes visible

Rdoc

  • docstrings
  • documentation about followed conventions

Screenshots

navbar group form group-2

Checklist

  • I have read and followed the CONTRIBUTING guide.
  • I confirm that I have the authority necessary to make this contribution on behalf of its copyright owner and agree to license it to the TeSS codebase under the BSD license.

Valentin Ryckaert and others added 30 commits June 12, 2026 09:01
@fbacall

fbacall commented Jul 28, 2026

Copy link
Copy Markdown
Member

Where can I find those screenshots?

https://github.com/ElixirTeSS/TeSS/actions/runs/30343552464?pr=1339

Scroll to the bottom.

Looks like the user is not authenticated in the screenshots.

@valentinRyckaert

Copy link
Copy Markdown
Contributor Author

Looks like the user is not authenticated in the screenshots.

Maybe the tests pipeline has a problem?

@fbacall

fbacall commented Jul 29, 2026

Copy link
Copy Markdown
Member

Looks like the user is not authenticated in the screenshots.

Maybe the tests pipeline has a problem?

The current tests do not authenticate any user: https://github.com/valentinRyckaert/TeSS-private-spaces/blob/refs/heads/private-spaces-with-groups/test/system/groups_test.rb

I get the same failures locally:

finn@finn-vmw-work:~/workspace/tess$ rails test:system

# Running tests with run options --seed 60505:

INFO  2026-05-20 12:00:00 UTC pid=10482 tid=b56: Sidekiq 8.1.6 connecting to Redis with options {size: 10, pool_name: "internal", url: "redis://localhost:6379/0"}
Capybara starting Puma...
* Version 8.0.2, codename: Into the Arena
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:43973
.[Screenshot Image]: /home/finn/workspace/tess/tmp/screenshots/failures_test_should_create_group.png 
E
Error:
GroupsTest#test_should_create_group:
Capybara::ElementNotFound: Unable to find field "Title" that is not disabled
    test/system/groups_test.rb:17:in 'block in <class:GroupsTest>'
[Screenshot Image]: /home/finn/workspace/tess/tmp/screenshots/failures_test_should_destroy_Group.png 
E
Error:
GroupsTest#test_should_destroy_Group:
Capybara::ElementNotFound: Unable to find link or button "Destroy this group"
    test/system/groups_test.rb:37:in 'block in <class:GroupsTest>'
[Screenshot Image]: /home/finn/workspace/tess/tmp/screenshots/failures_test_should_update_Group.png 
E
Error:
GroupsTest#test_should_update_Group:
Capybara::ElementNotFound: Unable to find link or button "Edit this group"
    test/system/groups_test.rb:26:in 'block in <class:GroupsTest>'
[Screenshot Image]: /home/finn/workspace/tess/tmp/screenshots/failures_test_visiting_the_index.png 
F
Failure:
GroupsTest#test_visiting_the_index [test/system/groups_test.rb:10]
Minitest::Assertion: expected to find css "h1" but there were no matches


Finished tests in 10.532783s, 0.4747 tests/s, 0.2848 assertions/s.


Slowest tests:

2.291584s test_should_create_group#GroupsTest
2.222092s test_should_destroy_Group#GroupsTest
2.201399s test_visiting_the_index#GroupsTest
2.181835s test_should_update_Group#GroupsTest
1.630357s test_calendar_tab_loads_and_renders_events_with_javascript#EventsCalendarSystemTest

5 tests, 3 assertions, 1 failures, 3 errors, 0 skips
Coverage report generated for Minitest to /home/finn/workspace/tess/coverage. 2563 / 4674 LOC (54.84%) covered.
Lcov style coverage report generated for Minitest to /home/finn/workspace/tess/coverage/lcov/tess.lcov

Not sure why they pass for you

@kennethrioja

Copy link
Copy Markdown
Contributor

[testing using a docker container, fetching this PR]

While adding a member to a group, it didn't show the proper UI (see 2nd screenshot) – I had a Uncaught TypeError: HandlebarsTemplates[opts.templateName] is not a function at HTMLInputElement.onSelect (application-0331ce8bb968713a1237041d52846697f50923c8c442e1cfce61da427ac28a66.js:77218:78)

I needed to do docker exec -it tess-app bundle exec rake assets:clobber tmp:clear and remove what's under tmp/cache, now it works

@fbacall fbacall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some initial comments.

General points:

  • I think the way private space resources are hidden from search results should be revisited - in its current state I think it could result in a user clicking through numerous empty pages of results (if, for example, a private space just added a large amount of content).
  • Any text that appears in the UI, try and add it to config/locales/en.yml so it can be changed/translated on different instances. Look at how this is done in other views. There are also methods to do this for class/attribute names e.g. Group.model_name.human, Group.human_attribute_name(:members)
  • Use SASS variables for any colours (or avoid custom colours in general and use classes from Bootstrap), so things look consistent if the theme is changed. References: https://getbootstrap.com/docs/3.4/components/ and https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss#L19-L23

Comment thread app/assets/config/manifest.js Outdated
Comment thread app/controllers/concerns/searchable_index.rb Outdated
Comment thread app/controllers/application_controller.rb Outdated
Comment thread app/controllers/materials_controller.rb Outdated
Comment thread app/models/space.rb
Comment thread app/views/groups/show.html.erb Outdated
Comment thread app/views/groups/index.html.erb
Comment thread app/policies/application_policy.rb Outdated
Comment thread app/views/groups/show.html.erb Outdated
Comment thread db/schema.rb
@fbacall
fbacall merged commit 8c159b4 into ElixirTeSS:master Aug 6, 2026
9 checks passed
@valentinRyckaert
valentinRyckaert deleted the private-spaces-with-groups branch August 6, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants