Repository: translate/pootle

Issue:
Allow language managers to edit their language's special characters
Essentially, it used to be that project admins could add their own special characters to the virtual keyboards for their project. There was an option for it in the project description portion of the project landing page. It appears that the field for adding special characters via that workflow has been removed.

Use case: Julio Gomes, who has been mentor for many indigenous Latin American locales, is project admin for each of these locales. After they were created in Pootle, he would do additional research into the writing systems for each locale and add those special character keys on his own within the project's description editing dialogue. Julio's request is to have it restored.



Discussion:
Some added info on this.  The ability to add a language description page also had the ability to edit the special characters.  Currently on `master` these changes can only be made at the global admin level.

I think we should look at exposing more of these config options on the Browse/Translate dropdown for language admin.

That would include:
1. Special characters
2. Language descriptions page (possibly)

I think that would be a great place for them.

Plan of action:
- Add some intermediate level of permissions between regular users and global admin, so some users can edit settings and announcements for specific TPs, Languages or Projects.
- If allowing such users to visit the admin site is deemed too dangerous or undesirable, then provide some new admin UI that just allows to edit a single TP, Language or Project.
- Consider displaying the links to access admin UIs in the actions dropdown:

![abbb](https://cloud.githubusercontent.com/assets/939880/9177109/9ee3564e-3f8f-11e5-9723-857e651ef378.png)

> Add some intermediate level of permissions between regular users and global admin, so some users can edit settings and announcements for specific TPs, Languages or Projects

@unho, we already have project-level admins, which could be a good fit for the purpose.

@iafan How do you specify a user to be a project-level admin? I have been checking existing permissions and I didn't saw any that can be checked to tell that a user is a project manager (I do prefer this term over admin, which I only use for global-admin or superuser).

@unho, try going to e.g. https://translate.stage.evernote.com/projects/website3_evernote/admin/permissions/ — there you can add a user with 'Can administrate a translation project' permission.

> @unho, try going to e.g. https://translate.stage.evernote.com/projects/website3_evernote/admin/permissions/ — there you can add a user with 'Can administrate a translation project' permission.

I thought that particular permission was to give some user TP manager rights. But independently of if this permission is "project manager" or "TP manager", I think we lack "language manager".

I think 'administering translation project' can include both adding permissions and providing descriptions. No need for another permission type, IMO. Let's keep things simple.

Created issue #3984 to track announcements edit for users with `administrate` permission.


Resolving patch:
diff --git a/pootle/apps/pootle_language/forms.py b/pootle/apps/pootle_language/forms.py
new file mode 100644
--- /dev/null
+++ b/pootle/apps/pootle_language/forms.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) Pootle contributors.
+#
+# This file is a part of the Pootle project. It is distributed under the GPL3
+# or later license. See the LICENSE file for a copy of the license and the
+# AUTHORS file for copyright and authorship information.
+
+from django import forms
+from django.utils.translation import ugettext_lazy as _
+
+from .models import Language
+
+
+class LanguageSpecialCharsForm(forms.ModelForm):
+
+    class Meta:
+        model = Language
+        fields = ('specialchars',)
diff --git a/pootle/apps/pootle_language/urls.py b/pootle/apps/pootle_language/urls.py
--- a/pootle/apps/pootle_language/urls.py
+++ b/pootle/apps/pootle_language/urls.py
@@ -27,4 +27,7 @@
     url(r'^(?P<language_code>[^/]*)/admin/permissions/$',
         'language_admin',
         name='pootle-language-admin-permissions'),
+    url(r'^(?P<language_code>[^/]*)/admin/characters/$',
+        'language_characters_admin',
+        name='pootle-language-admin-characters'),
 )
diff --git a/pootle/apps/pootle_language/views.py b/pootle/apps/pootle_language/views.py
--- a/pootle/apps/pootle_language/views.py
+++ b/pootle/apps/pootle_language/views.py
@@ -7,7 +7,7 @@
 # or later license. See the LICENSE file for a copy of the license and the
 # AUTHORS file for copyright and authorship information.
 
-from django.shortcuts import render
+from django.shortcuts import redirect, render
 
 from pootle.core.browser import (make_project_item,
                                  get_table_headings)
@@ -19,6 +19,8 @@
 from pootle.i18n.gettext import tr_lang
 from pootle_app.views.admin.permissions import admin_permissions
 
+from .forms import LanguageSpecialCharsForm
+
 
 @get_path_obj
 @permission_required('view')
@@ -108,3 +110,23 @@ def language_admin(request, language):
     }
     return admin_permissions(request, language.directory,
                              'languages/admin/permissions.html', ctx)
+
+
+@get_path_obj
+@permission_required('administrate')
+def language_characters_admin(request, language):
+    form = LanguageSpecialCharsForm(request.POST if request.method == 'POST'
+                                                 else None, instance=language)
+    if form.is_valid():
+        form.save()
+        return redirect('pootle-language-browse', language.code)
+
+    ctx = {
+        'page': 'admin-characters',
+
+        'language': language,
+        'directory': language.directory,
+        'form': form,
+    }
+
+    return render(request, 'languages/admin/characters.html', ctx)


Test patch: