mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
88cd2f8675
- Do not display anymore the identifier field in home. - Let the user enter the id if the slug generated from project name already exists as a project id. - Moved get_billform_for from 'utils' to 'forms', to avoid issue (was 'from forms import ...' into utils, and 'from utils import ...' into forms, which causeed an error).
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
import re
|
|
from functools import wraps
|
|
from flask import redirect, url_for, session, request
|
|
from werkzeug.routing import HTTPException, RoutingException
|
|
|
|
def slugify(value):
|
|
"""Normalizes string, converts to lowercase, removes non-alpha characters,
|
|
and converts spaces to hyphens.
|
|
|
|
Copy/Pasted from ametaireau/pelican/utils itself took from django sources.
|
|
"""
|
|
if type(value) == unicode:
|
|
import unicodedata
|
|
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
|
|
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
|
|
return re.sub('[-\s]+', '-', value)
|
|
|
|
class Redirect303(HTTPException, RoutingException):
|
|
"""Raise if the map requests a redirect. This is for example the case if
|
|
`strict_slashes` are activated and an url that requires a trailing slash.
|
|
|
|
The attribute `new_url` contains the absolute destination url.
|
|
"""
|
|
code = 303
|
|
|
|
def __init__(self, new_url):
|
|
RoutingException.__init__(self, new_url)
|
|
self.new_url = new_url
|
|
|
|
def get_response(self, environ):
|
|
return redirect(self.new_url, 303)
|