Skip to content

Rework StoreChain

KoeMai requested to merge 1620_add_endpoint_to_fetch_single_element into master

Closes #1620

What does this MR do?

This MR refactors and reworks the backend of the Store Chain Management and simplified input in the frontend. It is discussed in the product team.

The rework contains

  • Add validation of inputs, so that no invalid data can get into database.
  • Permission checks, so that only allowed users can access the information.
  • Add GET endpoint for single Chain
  • Rework on all endpoint for chains
  • Fix smaller issues in frontend
    • Allow postcodes with 4 digits
    • Add estimated numbers of stores
    • Dialog stays open with errors on server side are detected
  • Edit and Add Storechain
    • User search for KeyAccountManagers (User need to be member of AG StoreChain)
    • Thread search (Only AG StoreChain Threads)

Information which are stored in store chain.

Field Required information (can not be empty) Field description
ID (Auto) Unique identifier of the chain.
Name X Name of the chain.
Status X Indicates the cooperation status of this chain.
HeadquartersZip X ZIP code of the chains headquater.
HeadquartersCity X City of the chains headquater.
AllowPress X Whether the chain can be referred to in press releases.
ForumThread X Identifier of a forum thread related to this chain for AG internal notes/discussions.
Notes/hinweis - Information about the Status / current summary
CommonStoreInformation - Information for working with the chain to be displayed on related store page.
estimated_store_count - NEW FIELD - Expected forecast for count of stores.
StoreCount - The count of stores that are part of this chain.
Kams - List of Key account managers of store chain.
ModificationDate (Auto) Date of the last update to this chains entry.
regionId (const) Related region/ag of the store chain, this is always 332 only required for URL generation and increase flexibility in future when the backend contains the information
  • "X": Required

  • "-": Optional

  • Implement estimated_store_count

Access permission to store chain endpoints

Endpoint http Method Function Anonym unverifzierter Foodsaver Storeteam-Member when Store NOT belongs to chain Storeteam-Member when Store belongs to chain Foodsharer AG StoreChain Member AG StoreChain Admin StoreManager Orga KeyAccountManager
chains POST Create a new chain - - - - - - X - X -
chains GET List all chains - - - X* - X X X* X X
chains/{id} GET Get chain information - - - X* - X X X* X X
chains/{id} PATCH Update a chain - - - - - - X - X X*
chains/{id}/stores GET List all stores of chain - - - - - X X - X X

*Not allowed to chain or get all information

Information read permission for GET of chains and chains/{id}

Field Anonym unverifzierter Foodsaver Storeteam-Member when Store NOT belongs to chain Storeteam-Member when Store belongs to chain Foodsharer AG StoreChain Member AG StoreChain Admin StoreManager Orga
ID - X** X ** X X ** X X X X
Name - X** X ** X X ** X X X X
Status - - - X - X X X X
Headquarters_zip - - - X - X X X X
Headquarters_city - - - X - X X X X
Modification_date - - - X - X X X X
Allow_press - - - X - X X X X
Forum_thread - - - - - X X - X
Notes/hinweis - - - - - X X - X
Common_store_information - - - X - X X X X
estimated_store_count - - - - - X X - X
Store_count - - - - - X X - X
Kams - - - X - X X X X

** Via Endpoint GetMetaData for Stores

DB changes

  • Foreign key goes to wrong table, need to be replaced
  • We need to change the DB so I added preparation for fulltext search on server side

UI Update

image

How confident are you it won't break things if deployed?

Links to related issues

How to test

  1. Checkout branch locally
  2. Login as in different rules
  3. Try to create a store chain
  4. Try to update a store chain
  5. Try to view the stores of the chain

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • set a "for:" label to indicate who will be affected by this change
  • added to the next milestone (see https://gitlab.com/foodsharing-dev/foodsharing/-/milestones, unless it has a "for:Dev" label)
  • added an entry to CHANGELOG.md
  • added a short text that can be used in the release notes
  • Once your MR has been merged, you are responsible to create a testing issue in the Beta Testing forum: https://foodsharing.de/?page=bezirk&bid=734&sub=forum. Please change the MRs label to "state:Beta testing".
    • Consider writing a detailed description in German.
    • Describe in a few sentences, what should be tested from a user perspective.
    • Also mention different settings (e.g. different browsers, roles, ...) how this change can be tested.
    • Be aware, that also non technical people should understand.

Release notes text in German

Edited by KoeMai

Merge request reports