Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #738 from City-of-Helsinki/release/v0.12.0
Browse files Browse the repository at this point in the history
Release/v0.12.0
  • Loading branch information
tommimanbytes authored Sep 23, 2020
2 parents 7464fbf + f9d71cc commit 249ec0e
Show file tree
Hide file tree
Showing 30 changed files with 931 additions and 95 deletions.
30 changes: 30 additions & 0 deletions docs/accessibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Resource accessibility data
===========================

In order to not replicate the complete Accessibility API, Respa stores an accessibility summary for each Resource using the Accessibility API.

This accessibility data can be used for querying Resources based on how accessible they are.

From the Accessibility API a list of Viewpoints is imported. These can be for example:

```
"I am a wheelchair user",
"I am a wheelchair user - arrive by my car",
"I am a wheelchair user - arrive with pick-up and drop-off traffic",
"I have reduced mobility, but I walk",
"I have reduced mobility, but I walk - arrive by my car",
"I have reduced mobility, but I walk - arrive with pick-up and drop-off traffic",
"I am a rollator user",
"I am a rollator user - arrive by my car",
"I am a rollator user - arrive with pick-up and drop-off traffic",
"I am a stroller pusher",
"I am visually impaired",
"I am visually impaired - arrive with pick-up and drop-off traffic",
"I use a hearing aid"
```

Each of these Viewpoints have a Value, or level of accessibility, represented as strings "red", "green" or "unknown" for inaccessible, accessible and unknown respectively. These Value types are also imported from the Accessibility API.

For example a Resource can be associated to a Viewpoint "I am a wheelchair user" and this association also points to the Value "green", meaning that the Resource is wheelchair accessible.

More detailed accessibility data can be fetched directly from the Accessibility API.
37 changes: 36 additions & 1 deletion locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ msgstr "Maksimilukumäärää ei voi ylittää"
msgid "This product isn't available on the resource."
msgstr "Tämä tuote ei ole saatavilla tällä resurssilla."

msgid "Begin time must be before end time"
msgstr "Alkamisajan täytyy olla päättymisaikaa aiempi"

msgid "At least one order line required."
msgstr "Vähintään yksi tilausrivi tarvitaan."

Expand Down Expand Up @@ -518,6 +521,10 @@ msgstr "Tällä kentällä ei voi olla arvoa tällä resurssilla"
msgid "This field cannot be changed"
msgstr "Tätä arvoa ei voi muuttaa"

#, python-format
msgid "Patching of field %(field)s is not allowed"
msgstr "Kentän %(field)s päivittäminen PATCH-metodilla ei ole sallittu"

#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr "Virheellinen pk \"{pk_value}\" - kohdetta ei ole olemassa."
Expand Down Expand Up @@ -571,6 +578,9 @@ msgstr "Resurssin saavutettavuus"
msgid "Resource"
msgstr "Resurssi"

msgid "Accessibility shortage count"
msgstr "Saavutettavuuspuutteiden määrä"

msgid "Resource ordering priority"
msgstr "Resurssin järjestysprioriteetti"

Expand Down Expand Up @@ -899,6 +909,30 @@ msgstr "Varauksen metatietojoukko"
msgid "Reservation metadata sets"
msgstr "Varauksen metatietojoukot"

msgid "Confirmed reservation"
msgstr "Vahvistettu varaus"

msgid "Requested reservation"
msgstr "Alustava varaus"

msgid "Own reservation"
msgstr "Oma varaus"

msgid "Reservation type"
msgstr "Varaustyyppi"

msgid "Reservation cancellation reason category"
msgstr "Varauksen peruutussyykategoria"

msgid "Reservation cancellation reason categories"
msgstr "Varauksen peruutussyykategoriat"

msgid "Reservation cancellation reason"
msgstr "Varauksen peruutussyy"

msgid "Reservation cancellation reasons"
msgstr "Varauksen peruutussyyt"

msgid "Invalid value"
msgstr "Epäkelpo arvo"

Expand Down Expand Up @@ -1466,7 +1500,8 @@ msgstr "Yhteyshenkilö"
msgid ""
"Contact person information is shown when customer cancels manually handled "
"reservations."
msgstr "Yhteyshenkilön tiedot näytetään asiakkaan peruessa käsiteltäviä varauksia."
msgstr ""
"Yhteyshenkilön tiedot näytetään asiakkaan peruessa käsiteltäviä varauksia."

msgid "External calendar"
msgstr "Ulkoinen kalenterijärjestelmä"
Expand Down
37 changes: 36 additions & 1 deletion locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ msgstr "Kan inte överskrida den maximala produktkvantiteten"
msgid "This product isn't available on the resource."
msgstr "Den här produkten är inte tillgänglig på resursen."

msgid "Begin time must be before end time"
msgstr "Starttid måste vara före sluttid"

msgid "At least one order line required."
msgstr "Minst en beställningsrad krävs."

Expand Down Expand Up @@ -514,6 +517,10 @@ msgstr "Det här fältet kan inte ha ett värde med den här resursen"
msgid "This field cannot be changed"
msgstr "Detta fält kan inte modifieras"

#, python-format
msgid "Patching of field %(field)s is not allowed"
msgstr "Uppdatering av fältet %(field)s är inte tillåtet med patch-metoden"

#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr "Felaktig pk \"{pk_value}\" - objektet existerar inte."
Expand Down Expand Up @@ -567,6 +574,9 @@ msgstr "Resurstillgänglighet"
msgid "Resource"
msgstr "Resurs"

msgid "Accessibility shortage count"
msgstr "Antal tillgänglighetsbrister"

msgid "Resource ordering priority"
msgstr "Resursordningsprioritet"

Expand Down Expand Up @@ -896,6 +906,30 @@ msgstr "Metadata för reservation"
msgid "Reservation metadata sets"
msgstr "Metadatauppsättningar för reservation"

msgid "Confirmed reservation"
msgstr "Bekräftad reservation"

msgid "Requested reservation"
msgstr "Begärd bokning"

msgid "Own reservation"
msgstr "Egen reservation"

msgid "Reservation type"
msgstr "Bokningstyp"

msgid "Reservation cancellation reason category"
msgstr "Skälkategori för annullering av bokning"

msgid "Reservation cancellation reason categories"
msgstr "Skälkategorier för annullering av bokning"

msgid "Reservation cancellation reason"
msgstr "Skäl för annullering av bokning"

msgid "Reservation cancellation reasons"
msgstr "Skäl för annullering av bokning"

msgid "Invalid value"
msgstr "Ogiltigt värde"

Expand Down Expand Up @@ -1459,7 +1493,8 @@ msgstr "Kontaktperson"
msgid ""
"Contact person information is shown when customer cancels manually handled "
"reservations."
msgstr "Kontaktpersoninformation visas när kunden avbokar manuellt reservationer."
msgstr ""
"Kontaktpersoninformation visas när kunden avbokar manuellt reservationer."

msgid "External calendar"
msgstr "Externt kalendersystem"
Expand Down
133 changes: 130 additions & 3 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: Respa
description: The Respa API provides categorized data on resources available for reservation within a city or metropolitan area
and enables the reservation of these resources. The API provides data in the JSON format, in a RESTful fashion.
version: 1.6.1
version: 1.6.2
servers:
- url: https://api.hel.fi/respa/v1
- url: https://respa.koe.hel.ninja/v1
Expand Down Expand Up @@ -90,6 +90,12 @@ paths:
based on the boolean value given.
schema:
type: boolean
- name: include
in: query
description: Include extra data to queryset. Currently accepts value `accessibility_summaries`.
schema:
type: string
example: accessibility_summaries
responses:
200:
description: Successful response
Expand Down Expand Up @@ -526,14 +532,20 @@ paths:
in: query
description: Order queryset by given resource fields, accepted values are
`resource_name_fi`, `resource_name_en`, `resource_name_sv`, `unit_name_fi`,
`unit_name_en`, `unit_name_sv`, `type`, `people_capacity`. Prefix parameter
`unit_name_en`, `unit_name_sv`, `type`, `people_capacity`, `accessibility`. Prefix parameter
value with `-` to get reverse ordering.
schema:
type: string
example: resource_name_fi
- name: accessibility_viewpoint
in: query
description: Use together with `order_by` `accessibility`. Determines the viewpoint for accessibility ordering using the viewpoint ID.
schema:
type: number
example: 11
- name: include
in: query
description: Include extra data to queryset. Currently accepts value `unit_detail`.
description: Include extra data to queryset. Currently accepts values `unit_detail`, `accessibility_summaries`.
schema:
type: string
example: unit_detail
Expand Down Expand Up @@ -852,6 +864,51 @@ paths:
non_field_errors:
type: string
description: The reason the change was not accepted
patch:
tags:
- reservation
description: The reservation endpoint allows changing state of reservation with a reason message
parameters:
- name: id
in: path
description: Unique identifier of the reservation in the reservation system.
required: true
schema:
type: string
requestBody:
description: The reservation data you wish to edit. State and cancel reason currently allowed with patch.
content:
'application/json':
schema:
properties:
state:
description: New state for the reservation
type: string
cancel_reason:
description: Reason object for reservation cancellation / denial
type: object
$ref: '#/components/schemas/cancel_reason_write'
required:
- status
responses:
200:
description: Successful response
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/reservation'
- $ref: '#/components/schemas/order_just_id'
400:
description: Bad request
content:
application/json:
schema:
type: object
properties:
non_field_errors:
type: string
description: The reason the change was not accepted
delete:
tags:
- reservation
Expand Down Expand Up @@ -885,6 +942,24 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/order_check_price_response'
/cancel_reason_category/:
get:
tags:
- cancel_reason
description: Predefined categories for cancellation reason for reservations. Includes predefined notification messages in all languages.
parameters:
- name: reservation_type
in: query
description: "Filtering parameter for type of reservation for which this cancel reason category is used. Choices: confirmed, requested, own."
schema:
type: string
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/cancel_reason_category'

components:
schemas:
Expand Down Expand Up @@ -1251,6 +1326,8 @@ components:
reserver_email_address:
type: string
description: Reserver email address
cancel_reason:
$ref: '#/components/schemas/cancel_reason_read'
equipment:
type: object
properties:
Expand Down Expand Up @@ -1496,3 +1573,53 @@ components:
allOf:
- $ref: '#/components/schemas/order_response_base'
- $ref: '#/components/schemas/order_check_price_base'
cancel_reason_write:
type: object
properties:
description:
type: string
description: Free description of reason of reservations cancellation
category_id:
type: integer
description: Id of reservation cancellation reason category to be used for cancellation
cancel_reason_read:
type: object
properties:
description:
type: string
description: Free description of reason of reservations cancellation
category:
$ref: '#/components/schemas/cancel_reason_category'
cancel_reason_category:
type: object
properties:
id:
type: integer
description: Id of the category
reservation_type:
type: string
description: "Type of reservation for which this cancel reason category is used. Choices: confirmed, requested, own."
name:
type: object
properties:
sv:
type: string
description: Swedish name for the cancel reason category
fi:
type: string
description: Finnish name for the cancel reason category
en:
type: string
description: English name for the cancel reason category
description:
type: object
properties:
sv:
type: string
description: Swedish full description for the cancel reason category
fi:
type: string
description: Finnish full description for the cancel reason category
en:
type: string
description: English full description for the cancel reason category
9 changes: 9 additions & 0 deletions payments/api/order.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers, viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
Expand All @@ -24,6 +25,14 @@ def __init__(self, *args, **kwargs):
# None means "all", we don't want product availability validation
self.context['available_products'] = None

def validate(self, attrs):
attrs = super().validate(attrs)
begin = attrs['begin']
end = attrs['end']
if end < begin:
raise serializers.ValidationError(_('Begin time must be before end time'), code='invalid_date_range')
return attrs


class OrderViewSet(viewsets.ViewSet):
@action(detail=False, methods=['POST'])
Expand Down
Loading

0 comments on commit 249ec0e

Please sign in to comment.