Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
42d9980a
Commit
42d9980a
authored
Mar 30, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding words to dictionary
parent
353f99b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
html/dictionary.html
html/dictionary.html
+12
-0
trans/forms.py
trans/forms.py
+4
-0
trans/views.py
trans/views.py
+15
-1
No files found.
html/dictionary.html
View file @
42d9980a
...
...
@@ -13,6 +13,8 @@
{% if words.object_list %}
<h2>
{% trans "Dictionary" %}
</h2>
<table>
<thead>
<tr>
...
...
@@ -49,5 +51,15 @@
</ul>
{% endif %}
<h2>
{% trans "Add new word" %}
</h2>
<form
method=
"POST"
>
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input
type=
"submit"
value=
"{% trans "
Add
"
%}"
/>
</form>
{% endblock %}
trans/forms.py
View file @
42d9980a
...
...
@@ -113,3 +113,7 @@ class AutoForm(forms.Form):
choices
=
[(
s
.
slug
,
s
.
name
)
for
s
in
obj
.
subproject
.
project
.
subproject_set
.
exclude
(
id
=
obj
.
subproject
.
id
)]
super
(
AutoForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'subproject'
].
choices
=
[(
''
,
_
(
'All subprojects'
))]
+
choices
class
WordForm
(
forms
.
Form
):
source
=
forms
.
CharField
(
label
=
_
(
'Source'
))
target
=
forms
.
CharField
(
label
=
_
(
'Translation'
))
trans/views.py
View file @
42d9980a
...
...
@@ -13,7 +13,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from
trans.models
import
Project
,
SubProject
,
Translation
,
Unit
,
Suggestion
,
Check
,
Dictionary
,
Change
from
lang.models
import
Language
from
trans.forms
import
TranslationForm
,
UploadForm
,
SimpleUploadForm
,
ExtraUploadForm
,
SearchForm
,
MergeForm
,
AutoForm
from
trans.forms
import
TranslationForm
,
UploadForm
,
SimpleUploadForm
,
ExtraUploadForm
,
SearchForm
,
MergeForm
,
AutoForm
,
WordForm
from
util
import
is_plural
,
split_plural
,
join_plural
from
accounts.models
import
Profile
from
whoosh.analysis
import
StandardAnalyzer
,
StemmingAnalyzer
...
...
@@ -137,6 +137,19 @@ def show_dictionary(request, project, lang):
prj
=
get_object_or_404
(
Project
,
slug
=
project
)
lang
=
get_object_or_404
(
Language
,
code
=
lang
)
if
request
.
method
==
'POST'
:
form
=
WordForm
(
request
.
POST
)
if
form
.
is_valid
():
Dictionary
.
objects
.
create
(
project
=
prj
,
language
=
lang
,
source
=
form
.
cleaned_data
[
'source'
],
target
=
form
.
cleaned_data
[
'target'
]
)
return
HttpResponseRedirect
(
request
.
get_full_path
())
else
:
form
=
WordForm
()
words
=
Dictionary
.
objects
.
filter
(
project
=
prj
,
language
=
lang
).
order_by
(
'source'
)
limit
=
request
.
GET
.
get
(
'limit'
,
25
)
...
...
@@ -158,6 +171,7 @@ def show_dictionary(request, project, lang):
'project'
:
prj
,
'language'
:
lang
,
'words'
:
words
,
'form'
:
form
,
}))
def
show_project
(
request
,
project
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment