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

some stuff work \o/

parent 1291042b
Pipeline #120 passed with stage
......@@ -87,3 +87,4 @@ local_settings.py
.env
db.sqlite3
.idea/*
......@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('dictionary/', include('dictionary.urls')),
path('admin/', admin.site.urls),
]
# Generated by Django 2.1.4 on 2018-12-24 15:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dictionary', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='language',
name='conlang',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='word',
name='details',
field=models.CharField(blank=True, max_length=8192, null=True),
),
migrations.AlterField(
model_name='word',
name='etymology',
field=models.CharField(blank=True, max_length=8192, null=True),
),
migrations.AlterField(
model_name='word',
name='roots',
field=models.ManyToManyField(null=True, related_name='_word_roots_+', to='dictionary.Word'),
),
migrations.AlterField(
model_name='word',
name='translation',
field=models.ManyToManyField(null=True, related_name='_word_translation_+', to='dictionary.Word'),
),
]
# Generated by Django 2.1.4 on 2018-12-24 15:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dictionary', '0002_auto_20181224_1530'),
]
operations = [
migrations.AlterField(
model_name='word',
name='roots',
field=models.ManyToManyField(blank=True, related_name='_word_roots_+', to='dictionary.Word'),
),
migrations.AlterField(
model_name='word',
name='translation',
field=models.ManyToManyField(blank=True, related_name='_word_translation_+', to='dictionary.Word'),
),
]
......@@ -11,6 +11,7 @@ class Language(models.Model):
"""A general class to refer to languages, with its code and its name"""
code = models.CharField(max_length=4, primary_key=True)
name = models.CharField(max_length=128)
conlang = models.BooleanField(default=True)
def __str__(self):
return "{0.name} ({0.code})".format(self)
......@@ -59,12 +60,12 @@ class Word(models.Model):
word = models.CharField(max_length=128)
slug = models.CharField(max_length=128)
language = models.ForeignKey(Language, on_delete=models.CASCADE)
translation = models.ManyToManyField("self")
translation = models.ManyToManyField("self", blank=True)
gender = models.ForeignKey(Gender, on_delete=models.SET_NULL, null=True)
wordclass = models.ForeignKey(Wordclass, on_delete=models.SET_NULL, null=True)
details = models.CharField(max_length=8192, blank=True)
etymology = models.CharField(max_length=8192, blank=True)
roots = models.ManyToManyField("self")
details = models.CharField(max_length=8192, blank=True, null=True)
etymology = models.CharField(max_length=8192, blank=True, null=True)
roots = models.ManyToManyField("self", blank=True)
def __str__(self):
return self.word
......
{% extends 'dictionary/base.html' %}
{% load staticfiles %}
<!---------------------------------------------------------------------------->
<!-- Page d’accueil, sélection des deux langues -->
<!---------------------------------------------------------------------------->
{% block title %}Language selection{% endblock %}
{% block addhead %}
<link rel="stylesheet" href="{% static 'dictionary/index.css' %}" type="text/css" media="screen" />
{% endblock %}
{% block body %}
<message>Please select the languages you want to translate from and to.</message>
<langselect>
<form method="post" id="" action="" enctype="multipart/form-data">
{% csrf_token %}
<select name="sourcelang">
{% for lang in all_languages %}
<option value="{{lang.code}}">{{lang.name}}</option>
{% endfor %}
</select>
<select name="sourcelang">
{% for lang in all_languages %}
<option value="{{lang.code}}">{{lang.name}}</option>
{% endfor %}
</select>
<button type="submit">Let’s Go!</button>
</form>
</langselect>
{% endblock %}
{% extends 'dictionary/base.html' %}
{% load staticfiles %}
{% block title %}{{from_lang.name}} -> {{to_lang.name}}{% endblock %}
{% block addhead %}
<link rel="stylesheet" href="{% static 'dictionary/language.css'" type="text/css" media="screen" />
{% endblock %}
{% block body %}
<wordlist>
{% for word in words_initial %}
<wordblock>
<word>{{word.word}}</word>
<grammar>
<wclass>{{word.wordclass}}</wclass>
<gender>{{word.gender}}</gender>
</grammar>
{% for trans in word.translation.all %}
<translation>{{trans}} ({{trans.language.name}})</translation>
{% endfor %}
</wordblock>
{% endfor %}
</wordlist>
{% endblock %}
......@@ -8,21 +8,20 @@ urlpatterns = [
# choix du langage traduit et du langage de traduction
# /dictionary/
url(r'^$', views.index, name='index'),
# url(r'^$', views.index, name='index'),
path('', views.index, name='index'),
# renvoie la liste des lettres initiales des mots de `from_lang` enregistrés
# et prépare le renvoi vers la liste des mots commençant par cette initiale
# traduits vers `to_lang`
# 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>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/$',
views.indexlang,
url(r'^from=(?P<from_lang>\w+)/to=(?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/a
# /dictionary/from=HJLP/to=FRA/init=a
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/init=(?P<initial>\S)/$',
views.listwords,
name='listwords'),
......
from django.shortcuts import render
from django.utils.text import slugify
from django.views import generic
from django.views.generic import View
from .models import Language, Gender, Wordclass, Word
def index(request):
pass
def indexlang(request, from_lang, to_lang):
pass
all_languages = Language.objects.all()
return render(request, 'dictionary/index.html',
{'all_languages': all_languages})
def index_lang(request, from_lang, to_lang):
words_initial = Word.objects.filter(language__code=from_lang)
from_lang = Language.objects.get(code=from_lang)
to_lang = Language.objects.get(code=to_lang)
return render(request, 'dictionary/language.html', {
'words_initial': words_initial,
'from_lang': from_lang,
'to_lang': to_lang
})
def listwords(request, from_lang, to_lang, initial):
......
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