Skip to content

District pickup rule

- requested to merge district_pickup_rule into master

Closes #1422 (closed)

What does this MR do?

Introduces pickup rules for region. The Option page is now accessable for admins of the GOALS StoreCoordination group specific for the district rule On the option page of a region it is possible to define a pickuprule for maximum number of pickups within a timefrane. On store page it can be opt-in that the district rules applies to this store (additional to any other rule "social" the store itself has. If the region rule is active and the store is set to follow the rule as well then an information is shown on the store info box. In the region Options-page the stores are listed from the region that apply the region rule. If the user signs up for a slot it is checked against the region rule. If the check fails the user can not sign up for the slot.

TODO:

Region Options page:

  • have dropdown for region options setting -> changed to dropdown and range
  • if editfield then have input validation for number values -> no editfields
  • validation checks (not neccessary since input is limited)
  • add Test (?)
  • KLASSE explain tutorial
  • Better marking when a rule is violated and the button is deactive (maybe change color ?)

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

Not that bad.

Links to related issues

#1422 (closed)

How to test

  1. Checkout branch locally
  2. Login as userstorecoordination1@example.com (=Admin of GOALS Group Betriebskoordinationsteam)
  3. go to region-option page
  4. set / edit values for a rule
  5. define a rule that you can easily check (e.g.: high timeframe, low maximum numbers of pickups, low number of hours for inactivating rule before a pickup)
  6. go to a store
  7. edit store and set "Sollen für diesen Betrieb die Bezirksregeln für Abholungen gelten?" to yes
  8. only if store option is set to yes and region rule is set to active additional information about the rule is shown in the info box
  9. create slots try to sign up for slots till rule is invalid
  10. go to another store
  11. also set store option to follow district rule
  12. check that combined number of pickups violates your rule.
  13. go to another store in another district
  14. set store option to follow district rule (also the other district is has rule not active
  15. check that for the first district the pickups from the other store are also taken into account.

Screenshots (if applicable)

Go to region->Option page Here you can set a region pickup rule. "Maximum number of pickups in a timeframe. During one Day the maximum number of pickups is yy . In xx hours for a pickup the rule is inactive."

image

If you edit the store you can choose that this store follow the district rules:

image

If the store option is set AND the region pickup rule is set to active following information is displayed in the store-info-box

image

Region Option page for setting district rule

If a user tries to sign up and it violates the district rule an information is shown and the button stays disabled. image

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

Unter den Bezirksoptionen ist es nun möglich eine Abholregel auf Bezirksebene für eine maximale Anzahl an Abholungen innerhalb eines Zeitraumes (in Tagen)einzugeben, die Abholungen über mehrere Betriebe berücksichtigt. Hierbei kann auch eine insgesamte Maximale Anzahl an Abholungen pro Tag angegeben werden. Des Weiteren muss angegeben werden, wieviel Stunden vor der Abholung die Regel vom System ignoriert werden darf (bsp.: 24h). Betriebe, bei denen eingeschaltet ist, dass sie die Bezirksregel berücksichtigt werden, sind aufgelistet.

image

Bei Betrieben kann ausgewählt werden ob dieser bei der Bezirksweiten Abholregel berücksichtigt werden soll.

image

Ist eine Bezirksregel auf aktiv gesetzt und im Betrieb angegeben, das dieser bei der Bezirksregel berücksichtigt werden soll, wird in der Infobox die zusätzliche Regel angezeigt. Diese Regel wird vom System geprüft und gilt zusätzlich zu anderen aufgestellten Betriebsregeln, die anderweitig geprüft werden und einzuhalten sind.

image

Bei dem Überprüfen der Regel werden alle Abholungen gezählt, die bei Betrieben in dem Zeitraum stattgefunden haben, bei denen die Berücksichtigung der Bezirksregel eingeschaltet ist. Bei dem Versuch sich einzutragen wird die Bezirksregel geprüft. Sollte die maximale Anzahl an Abholungen erreicht worden sein so wird angezeigt, das die Bezirksregel nicht erfüllt ist. Der Knopf zum Eintragen bleibt deaktiviert.

image

Beispiel: Ein Bezirk hat 3 sehr beliebte Betriebe. Um hier ein Gleichgewicht und fairness sicherzustellen, wird sich darauf geeinigt das jeder nur 2 mal insgesamt innerhalb von 7 Tagen bei diesen abholen darf. Dabei spielt es keine Rolle bei welchen der drei Supermärkte die Abholung stattfindet solange die Gesamtanzahl in dem Zeitraum nicht überschritten wird. Es darf nicht mehr als 2 mal insgesamt PRO TAG bei diesen Betrieben abgeholt werden. Um sicherzustellen, dass es nicht dazu kommt, das sich niemand für eine Abholung eintragen kann, weil alle schon die Regel erfüllen, wird angegeben das 5 Stunden vor der Abholung die Regel vom System ignoriert werden darf.

Es wird als Bezirksregel

  • bei "Bitte gib den Zeitraum in Tagen an, in denen die Regelung gültig ist": 7,
  • bei "Bitte gib die maximale Anzahl der insgesamt möglichen Abholungen für diesen Zeitraum an:" 2
  • bei "Bitte gib die insgesamte maximale Anzzahl von Abholungen für EINEN TAG an::" 2
  • bei "Bitte gib die Anzahl Stunden vor einer Abholung an, in denen die Regel nicht mehr gilt:" 5

eingegeben.

Bei den Betrieben wird die Einstellung bei "Sollen für diesen Betrieb die Bezirksregeln für Abholungen gelten?" bei beiden Betrieben auf "Ja" gestellt. Sollte ein weitere Betrieb hinzugenommen werden kann die Regel entsprechend angepasst oder einfach nur bei dem Betrieb aktiviert werden.

Dies hat keinen Einfluss auf Abholungen bei Betrieben, die nicht für die Bezirksregel berücksichtigt werden sollen und ihre eigenen Regeln haben. Sollten Betriebe in verschiedenen Bezirken liegen, aber eingestellt haben, dass sie die Bezirksregel berücksichtigen, wird die jeweilige Regel des Bezirks diese mit einbeziehen. Jeder Bezirk überprüft seine Regel, berücksichtigt aber alle Abholungen bei den Betrieben, bei denen die Berücksichtigung aktiviert ist.

Edited by -

Merge request reports