Currently moving from Gitlab to Gitea at https://labs.phundrak.com. Some features may not work anymore on this Gitlab instance.

will continue working on this later

parent a637fac2
This diff is collapsed.
......@@ -4,17 +4,28 @@ from . import views
app_name = 'dict'
urlpatterns = [
# /dict/from=FRA/to=HJA/a
url(r'^from=(?P<sourcelang>[a-zA-Z]+)/(?P<destlang>[a-zA-Z]+)/(?P<initial>[a-zA-Z])/*$',
views.listwords,
name='listwords'),
# /dict/lang=HJA/tay => renvoie cinq mots commençant par `tay`
url(r'^lang=<language>[a-zA-Z]+\?\w/*$', views.guess, name='guess'),
url(r'^from=(?P<sourcelang>[a-zA-Z]+)/(?P<word>\w)/*$',
views.guess,
name='guess'),
# /dict/from=FRA/to=HJA/jour => renvoie le sommaire de la traduction de
# `jour`
url(r'^from=<sourcelang>\w/to=<destlang>\w/<word>\w/*$',
url(
r'^from=<sourcelang>\w/to=<destlang>\w/<word>\w/*$',
views.translate,
name='translate'),
name='translate',
),
# /dict/lang=HJA/details=bém
url(r'^lang=(?P<language>[a-zA-Z)+]/details=(?P<word>\w)/*$',
# /dict/from=HJA/details=bém
url(
r'^lang=(?P<language>[a-zA-Z)+]/details=(?P<word>\w)/*$',
views.details,
name='details'),
name='details',
),
]
from django.shortcuts import render
from .models import Word
from django.utils import slugify
from django.shortcuts import render, get_object_or_404
# Create your views here.
def listwords(request, sourcelang, destlang, initial):
all_words = Word.objects.filter(
name__startswith=initial, language=sourcelang)
return render(request, 'dict/index.html', {'all_words': all_words})
def guess(request, sourcelang, word):
all_words = Word.objects.filter(name__startswith=word, language=sourcelang)
return render(request, 'dict/index.html', {'all_words': all_words})
def translate(request, sourcelang, destlang, word):
detailed_word = get_object_or_404(Word, slug=slugify(word), language=sourcelang)
translations = get_object_or_404(Word, slug=slugify(word), language)
return render(request, 'dict/detailed.html', {'detailed_word': detailed_word})
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