Permalink
Browse files

Add preliminary L10n dashboard. p=fwenzel, p=clouserw, p=potch

  • Loading branch information...
1 parent 5eb496f commit bd5d3abce0bb16a4fb0cc9f941f74f2ddb5ea287 @fwenzel fwenzel committed with clouserw Feb 17, 2010
No changes.
View
@@ -0,0 +1,67 @@
+from django.conf import settings
+
+import jinja2
+from jingo import register
+from product_details import product_details
+
+from access import acl
+
+from .models import L10nSettings, L10nEventlog
+
+
+def _permission_to_edit_locale(request, locale=''):
+ """If locale is empty, it checks global permissions."""
+
+ if acl.action_allowed(request, 'Admin', 'EditAnyLocale'):
+ return True
+
+ if locale and acl.action_allowed(request, 'Localizers', locale):
+ return True
+
+ return False
+
+
+@register.inclusion_tag('localizers/sidebar.html')
+@jinja2.contextfunction
+def localizers_sidebar(context, locale_code=""):
+ """Sidebar on the per-locale localizer dashboard page."""
+ ctx = dict(context.items())
+ request = context['request']
+
+ ctx.update({
+ 'show_edit': _permission_to_edit_locale(request, locale_code),
+ 'locale_code': locale_code,
+ })
+ return ctx
+
+
+@register.inclusion_tag('localizers/sidebar_motd.html')
+@jinja2.contextfunction
+def localizers_sidebar_motd(context, lang=''):
+ """Message of the Day on localizer dashboards."""
+
+ request = context['request']
+
+ try:
+ l10n_set = L10nSettings.objects.get(locale=lang)
+ motd = l10n_set.motd
+ except L10nSettings.DoesNotExist:
+ motd = None
+
+ ctx = dict(context.items())
+ ctx.update({
+ 'motd_lang': lang,
+ 'motd': motd,
+ 'show_edit': _permission_to_edit_locale(request, lang),
+ })
+ return ctx
+
+
+@register.inclusion_tag('localizers/locale_switcher.html')
+def locale_switcher(current_locale=None):
+ """Locale dropdown to switch user locale on localizer pages."""
+ return {
+ 'current_locale': current_locale,
+ 'locales': settings.AMO_LANGUAGES + settings.HIDDEN_LANGUAGES,
+ 'languages': product_details.languages,
+ }
View
@@ -0,0 +1,37 @@
+from django.db import models
+
+import caching.base
+
+import amo.models
+from translations.fields import PurifiedField
+
+
+class L10nEventlog(caching.base.CachingMixin, models.Model):
+ locale = models.CharField(max_length=30, default='')
+ type = models.CharField(max_length=20, default='')
+ action = models.CharField(max_length=40, default='')
+ field = models.CharField(max_length=20, default='', null=True)
+ user = models.ForeignKey('users.UserProfile')
+ changed_id = models.PositiveIntegerField(
+ default=0, help_text='id of the object being affected by the change')
+ added = models.CharField(max_length=255, default='', null=True)
+ removed = models.CharField(max_length=255, default='', null=True)
+ notes = models.TextField()
+
+ created = models.DateTimeField(auto_now_add=True)
+
+ objects = amo.models.ManagerBase()
+
+ class Meta:
+ db_table = 'l10n_eventlog'
+ get_latest_by = 'created'
+
+
+class L10nSettings(amo.models.ModelBase):
+ """Per-locale L10n Dashboard settings"""
+ locale = models.CharField(max_length=30, default='', unique=True)
+ motd = PurifiedField()
+ team_homepage = models.CharField(max_length=255, default='', null=True)
+
+ class Meta:
+ db_table = 'l10n_settings'
@@ -0,0 +1,7 @@
+{% extends "impala/base.html" %}
+
+{% block title %}{{ page_title(_('Localizer Dashboard')) }}{% endblock %}
+
+{% block js %} {{ js('zamboni/localizers') }} {% endblock %}
+
+{% block bodyclass %}gutter{% endblock %}
@@ -0,0 +1,26 @@
+{% extends "localizers/base.html" %}
+
+{% block title %}
+{# L10n: %s is a locale name or code ('German' or 'de') #}
+{{ page_title(_('Localization Summary for {0}')|f(userlang['native'])) }}
+{% endblock %}
+
+{% block content %}
+
+<header>
+ {{ impala_breadcrumbs([(url('localizers.dashboard'), _('Localization Dashboard'))]) }}
+
+ <h1>{{ _('Category Localization for {0}')|f(userlang.native) }}</h1>
+
+ {{ locale_switcher(current_locale=locale_code) }}
+</header>
+
+{{ localizers_sidebar(locale_code=locale_code) }}
+<div class="primary c">
+
+ <section class="hero island c">
+ Future home of category L10n
+ </section>
+</div>{# /#primary #}
+
+{% endblock content %}
@@ -0,0 +1,44 @@
+{% extends "localizers/base.html" %}
+
+{% block title %}
+{# L10n: %s is a locale name or code ('German' or 'de') #}
+{{ page_title(_('Localization Summary for {0}')|f(userlang['native'])) }}
+{% endblock %}
+
+{% block content %}
+
+<header>
+ {{ impala_breadcrumbs([(url('localizers.dashboard'), _('Localization Dashboard'))]) }}
+
+ <h1>{{ _('Localization Summary for {0}')|f(userlang.native) }}</h1>
+
+ {{ locale_switcher(current_locale=locale_code) }}
+</header>
+
+{{ localizers_sidebar(locale_code=locale_code) }}
+<div class="primary c">
+
+ <section class="hero island c">
+ {% if members or team_homepage %}
+ {# L10n: {0} is a language name, e.g. 'Deutsch' #}
+ <h2>{{ _('Want to get in touch with the {0} L10n team?')|f(userlang['native']) }}</h2>
+ {% if team_homepage %}
+ <p><a href="{{ team_homepage|external_url }}" hreflang="{{ locale_code }}">
+ {# L10n: {0} is a language name, e.g. 'Deutsch' #}
+ {{ _('Visit the {0} L10n Homepage')|f(userlang['native']) }}
+ </a></p>
+ {% endif %}
+ {% if members %}
+ {# L10n: {0} is a language name, e.g. 'Deutsch' #}
+ <h2>{{ _('Current Localizers for {0}:')|f(userlang['native']) }}</h2>
+ <ul>
+ {% for member in members %}
+ <li>{{ member|user_link }}</li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ {% endif %}
+ </section>
+</div>{# /#primary #}
+
+{% endblock content %}
@@ -0,0 +1,11 @@
+<div id="localeswitcher">
+ <form method="get" action="">
+ <label for="userlang">{{ _('Change Locale:') }}</label>
+ <select id="userlang" name="userlang" onChange="this.form.submit();">
+ {% for locale in locales %}
+ <option value="{{ locale }}"{{ ' selected' if locale == current_locale }}>{{ languages[locale]['native'] }}</option>
+ {% endfor %}
+ </select>
+ <noscript><button type="submit">{{ _('Go') }}</button></noscript>
+ </form>
+</div>
@@ -0,0 +1,49 @@
+<section class="secondary" role="complementary">
+ <aside id="l10n-motd" class="notice">
+ {# L10n: Header to an info box in the sidebar #}
+ <h2>{{ _('Good to know') }}</h2>
+ {{ localizers_sidebar_motd() }}
+ {% if locale_code %}
+ <hr />
+ {{ localizers_sidebar_motd(lang=locale_code) }}
+ {% endif %}
+ </aside>
+
+ <aside class="notice">
+ <h2>{{ _('Want the bigger picture?') }}</h2>
+ <a class="button" href="http://localize.mozilla.org">
+ {{ ('Visit localize.mozilla.org') }}
+ </a>
+ </aside>
+
+ {% if locale_code %}
+ <div>
+ <h2>{{ _('Options') }}</h2>
+ <ul>
+ <li>
+ <a href="{{ url('localizers.categories', locale_code) }}">{{ _('Categories') }}</a>
+ </li>
+ </ul>
+ </div>
+
+ {% if show_edit %}
+ <div>
+ <h2>{{ _('Need Help?') }}</h2>
+ <p>
+ <a class="button" target="_blank" href="http://www.mozilla.org/community/developer-forums.html#dev-l10n-web">
+ {{ _('Visit the Newsgroup') }}
+ </a>
+ </p>
+
+ {% if members %}
+ <h3>{{ _('E-Mail Your Team:') }}</h3>
+ <ul>
+ {% for member in members %}
+ <li><a href="mailto:{{ member.email }}">{{ member.display_name }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </div>
+ {% endif %}
+ {% endif %}
+</section>
@@ -0,0 +1,19 @@
+<div class="motd">
+ {% if show_edit %}
+ <div class="edit_motd" style="display:none;">
+ <form action="{{ url('localizers.set_motd') }}" method="post">
+ {{ csrf() }}
+ <input type="hidden" name="lang" value="{{ motd_lang }}"/>
+ <textarea name="msg">{{ motd and motd.localized_string }}</textarea>
+ <button type="submit">{{ _('Submit') }}</button>
+ <a href="#" class="cancel">{{ _('Cancel') }}</a>
+ </form>
+ </div>
+ {% endif %}
+ <div class="motd_text">
+ <div class="msg">{{ motd }}</div>
+ {% if show_edit %}
+ <p class="edit"><a href="#">{{ _('(edit)') }}</a></p>
+ {% endif %}
+ </div>
+</div>
@@ -0,0 +1,50 @@
+{% extends "localizers/base.html" %}
+
+{% block title %}{{ page_title(_('Localizer Dashboard')) }}{% endblock %}
+
+{% block content %}
+
+ <header>
+ {{ impala_breadcrumbs([(url('localizers.dashboard'), _('Localization Dashboard'))]) }}
+ <h1>{{ _('Mozilla Add-ons Localization') }}</h1>
+ </header>
+
+ {{ localizers_sidebar() }}
+
+ <div class="primary c">
+ <section class="notice">
+ <h2>{{ _('Want to help?') }}</h2>
+ <p>{{ _('AMO is available in so many languages thanks to the help of people like you!') }}</p>
+ <p><a class="button" target="_blank" href="https://wiki.mozilla.org/AMO:Localizers">
+ {{ _('Get started with AMO L10n') }}
+ </a></p>
+ </section>
+ <section class="island hero c">
+ <h2>{{ _('Existing AMO locales') }}</h2>
+ <table style="width:100%">
+ <thead>
+ <tr>
+ <th>{{ ('Locale code') }}</th>
+ <th colspan="2">{{ ('Locale name') }}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for lang in amo_languages %}
+ <tr>
+ <td>{{ lang }}</td>
+ <td>
+ <a href="{{ url('localizers.locale_dashboard', lang) }}">
+ {{ languages[lang]['native'] }}
+ </a>
+ </td>
+ <td>
+ {{ languages[lang]['English'] }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </section>
+ </div>
+
+{% endblock content %}
View
@@ -0,0 +1,16 @@
+from django.conf.urls.defaults import patterns, url, include
+
+from . import views
+
+# These will all start with /localizers/<locale_code>/
+detail_patterns = patterns('',
+ url('^$', views.locale_dashboard, name='localizers.locale_dashboard'),
+ url('^categories/$', views.categories, name='localizers.categories'),
+)
+
+urlpatterns = patterns('',
+ ('^(?P<locale_code>[\w-]+)/', include(detail_patterns)),
+
+ url('^$', views.summary, name='localizers.dashboard'),
+ url('^set_motd$', views.set_motd, name='localizers.set_motd'),
+)
Oops, something went wrong.

0 comments on commit bd5d3ab

Please sign in to comment.