modified url schematics

parent 37039495
......@@ -12,32 +12,33 @@ urlpatterns = [
path('', views.index, name='index'),
# renvoie à la liste des mots de la première initiale de <from_lang>
# /dictionary/from=<from_lang>/to=<to_lang>/
# /dictionary/from=HJLP/to=FRA
url(r'^from=(?P<from_lang>\w+)/to=(?P<to_lang>\w+)/*$',
# /search/<from_lang>/<to_lang>/
# /search/HJP/FRA
# url(r'^from=(?P<from_lang>\w+)/to=(?P<to_lang>\w+)/*$',
url(r'^search/(?P<from_lang>\w+)/(?P<to_lang>\w+)/*$',
views.index_lang,
name='listinitials'),
# renvoie la liste des mots de `from_lang` et leur traduction abrégée en
# `to_lang` commençant par la lettre `initial`
# /dictionary/from=<from_lang>/to=<to_lang>/init=<initial>
# /dictionary/from=HJLP/to=FRA/init=a
url(r'^from=(?P<from_lang>\w+)/to=(?P<to_lang>\w+)/init=(?P<initial>\S)/*$',
# /search/<from_lang>/<to_lang>/<initial>
# /search/HJP/FRA/a
url(r'^search/(?P<from_lang>\w+)/(?P<to_lang>\w+)/(?P<initial>\S)/*$',
views.listwords,
name='listwords'),
# renvoie le détail de la traduction de `word` en `from_lang` vers
# `to_lang`
# /dictionary/from=<from_lang>/to=<to_lang>/word=<word>/
# /dictionary/from=HJLP/to=FRA/word=hj-lp
url(r'^from=(?P<from_lang>\w+)/to=(?P<to_lang>\w+)/word=(?P<word>[-\w0-9]+)/*$',
# /word/<from_lang>/<to_lang>/<word>/
# /word/HJP/FRA/hj-lp
url(r'^word/(?P<from_lang>\w+)/(?P<to_lang>\w+)/(?P<word>[-\w0-9]+)/*$',
views.details,
name='details'),
# renvoie cinq mots de `from_lang` commençant par `word`
# /dictionary/from=<from_lang>/guess/<word>/
# /dictionary/from=HJLP/guess=hj
url(r'^from=(?P<from_lang>\w+)/guess=(?P<word>[-\w0-9]+)/*$',
# /guess/<from_lang>/<word>/
# /guess/HJLP/hj
url(r'^guess/(?P<from_lang>\w+)/(?P<word>[-\w0-9]+)/*$',
views.guessword,
name='guessword'),
]
......@@ -24,9 +24,9 @@ def index(request):
to_lang = form.cleaned_data['to_lang']
print(from_lang.code + " and " + to_lang.code)
if from_lang.conlang != to_lang.conlang:
return HttpResponseRedirect('/from=' +
from_lang.code + '/to=' +
to_lang.code + '/')
return HttpResponseRedirect('/search/' +
from_lang.code + '/' +
to_lang.code)
error_message = "You cannot select two natural languages or two conlangs."
else:
print("NOT VALID")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment