Skip to content

Instantly share code, notes, and snippets.

View mathjazz's full-sized avatar

Matjaž Horvat mathjazz

View GitHub Profile
@mathjazz
mathjazz / experiment.diff
Created June 29, 2017 13:31
ActiveEntityTranslation experiment
diff --git a/pontoon/base/admin.py b/pontoon/base/admin.py
index d5a79e7..60f2d56 100644
--- a/pontoon/base/admin.py
+++ b/pontoon/base/admin.py
@@ -181,3 +181,4 @@ admin.site.register(models.Entity, EntityAdmin)
admin.site.register(models.Translation, TranslationAdmin)
admin.site.register(models.TranslationMemoryEntry, TranslationMemoryEntryAdmin)
admin.site.register(models.ChangedEntityLocale, ChangedEntityLocaleAdmin)
+admin.site.register(models.ActiveTranslation)
diff --git a/pontoon/base/migrations/0095_activetranslation.py b/pontoon/base/migrations/0095_activetranslation.py
diff --git a/pontoon/base/views.py b/pontoon/base/views.py
index dd503ad..15fc6ec 100755
--- a/pontoon/base/views.py
+++ b/pontoon/base/views.py
@@ -583,8 +583,9 @@ def update_translation(request):
if len(translations) > 0:
# Same translation exists
- try:
- t = translations.get(string=string)
diff --git a/pontoon/teams/static/css/team.css b/pontoon/teams/static/css/team.css
index b7ece35..456ab36 100644
--- a/pontoon/teams/static/css/team.css
+++ b/pontoon/teams/static/css/team.css
@@ -123,25 +123,37 @@
color: #7BC876;
}
-.info {
- text-align: center;
diff --git a/pontoon/sync/core.py b/pontoon/sync/core.py
index 90c86ec..dc002da 100644
--- a/pontoon/sync/core.py
+++ b/pontoon/sync/core.py
@@ -264,7 +264,7 @@ def get_changed_locales(db_project, locales):
# Requirement: all translation repositories must have API configured.
for repo in repos:
if not repo.api_config:
- return None
+ return locales
diff --git a/pontoon/sync/tasks.py b/pontoon/sync/tasks.py
index 5ac9c2d..77c2243 100644
--- a/pontoon/sync/tasks.py
+++ b/pontoon/sync/tasks.py
@@ -249,10 +249,10 @@ def sync_translations(
updated_entity_pks.append(db_entity.pk)
obsolete_entity_pks = project_changes['obsolete_db']
- changed_resources = db_project.resources.filter(
+ changed_resources = list(db_project.resources.filter(
diff --git a/pontoon/base/models.py b/pontoon/base/models.py
index f28c0ec..03437a9 100644
--- a/pontoon/base/models.py
+++ b/pontoon/base/models.py
@@ -2026,14 +2026,30 @@ class Entity(DirtyFieldsMixin, models.Model):
if search:
# https://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-valued-relationships
search_query = (search, locale.db_collation)
- entities = (
- Entity.objects.filter(
@mathjazz
mathjazz / asts.py
Last active December 18, 2017 16:02
A few examples of FTL Messages represented as JSONified ASTs
# Example 1:
{
"comment": null,
"span": {
"start": 0,
"end": 42,
"type": "Span"
},
"tags": [],
diff --git a/pontoon/base/context_processors.py b/pontoon/base/context_processors.py
index 7eb31dc..a974c21 100644
--- a/pontoon/base/context_processors.py
+++ b/pontoon/base/context_processors.py
@@ -1,4 +1,11 @@
from django.conf import settings
+from django.utils import translation
+
+
+def i18n(request):
diff --git a/pontoon/teams/views.py b/pontoon/teams/views.py
index 647d95a..c74d83e 100644
--- a/pontoon/teams/views.py
+++ b/pontoon/teams/views.py
@@ -122,12 +122,9 @@ def ajax_permissions(request, locale):
translators = l.translators_group.user_set.exclude(pk__in=managers).all()
all_users = User.objects.exclude(pk__in=managers).exclude(pk__in=translators).exclude(email='')
- contributors = (
- User.translators
@mathjazz
mathjazz / serializeExpression.js
Created January 24, 2018 12:42
serializeExpression
function serializeExpression(expression) {
if (expression.type === 'MessageReference') {
return expression.id.name;
}
if (expression.type === 'ExternalArgument') {
return '$' + expression.id.name;
}
if (expression.type === 'NumberExpression') {