Logo
Explore Help
Sign In
darkhelm/notifications-admin
1
0
Fork 0
You've already forked notifications-admin
mirror of https://github.com/GSA/notifications-admin.git synced 2026-08-24 16:24:08 -04:00
Code Issues Packages Projects Releases Wiki Activity
Files
61eaad9a9fdbff32e962da171721a62f65dd2b0b
notifications-admin/app/url_converters.py

12 lines
205 B
Python
Raw Normal View History

Add URL converters for template and file types Sometimes we manually check that a URL parameter is in a required set. Sometimes we don’t bother. This commit adds a URL converter to do this so that: - we don’t have to re-write the same code every time - it’s easier to apply this check to other endpoints This means endpoints that previously allowed a `template_type` or `message_type` of `None` now 404. So I’ve had to add new routes for with URLs that don’t include such parameters. So this…: ``` /services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications/sms.csv /services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications/None.csv ``` …becomes: ``` /services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications/sms.csv /services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications.csv ``` This matches what we do for the HTML-responding equivalent (see https://github.com/alphagov/notifications-admin/blob/265931d21746918c4ddfc19c4ad3f8cb5683c1bf/app/main/views/jobs.py#L215-L216)
2019-11-04 11:20:08 +00:00
from werkzeug.routing import BaseConverter
class TemplateTypeConverter(BaseConverter):
regex = '(?:email|sms|letter)'
class LetterFileExtensionConverter(BaseConverter):
regex = '(?:pdf|png)'
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.0 Page: 498ms Template: 42ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API