Permalink
Browse files

Merge branch 'dev' of github.com:pculture/unisubs into dev

  • Loading branch information...
2 parents c33c8a9 + b71f3c7 commit 6485a7c7df5c9775d77f221633d2fb76ceecb33e @nicksergeant nicksergeant committed Oct 9, 2012
Showing with 789 additions and 382 deletions.
  1. +68 −28 apps/teams/models.py
  2. +0 −2 apps/unisubs_compressor/templatetags/media_compressor.py
  3. +1 −0 apps/webdriver_testing/__init__.py
  4. 0 apps/webdriver_testing/api_v2/__init__.py
  5. +29 −0 apps/webdriver_testing/api_v2/test_language_resource.py
  6. +406 −0 apps/webdriver_testing/api_v2/test_subtitles_resource.py
  7. +45 −0 apps/webdriver_testing/api_v2/test_user_resources.py
  8. +5 −2 apps/webdriver_testing/data_factories.py
  9. +25 −7 apps/webdriver_testing/data_helpers.py
  10. +3 −2 apps/webdriver_testing/site_pages/video_language_page.py
  11. +0 −182 apps/webdriver_testing/test_api_v2.py
  12. +5 −7 apps/webdriver_testing/test_upload_subs.py
  13. +10 −1 apps/widget/rpc.py
  14. +100 −79 deploy/fabfile_new.py
  15. +1 −0 deploy/requirements.txt
  16. BIN locale/ar/LC_MESSAGES/django.mo
  17. +1 −1 locale/ar/LC_MESSAGES/django.po
  18. BIN locale/ast/LC_MESSAGES/django.mo
  19. +1 −1 locale/ast/LC_MESSAGES/django.po
  20. BIN locale/bg/LC_MESSAGES/django.mo
  21. +1 −1 locale/bg/LC_MESSAGES/django.po
  22. BIN locale/bn/LC_MESSAGES/django.mo
  23. +1 −1 locale/bn/LC_MESSAGES/django.po
  24. BIN locale/bs/LC_MESSAGES/django.mo
  25. +1 −1 locale/bs/LC_MESSAGES/django.po
  26. BIN locale/ca/LC_MESSAGES/django.mo
  27. +1 −1 locale/ca/LC_MESSAGES/django.po
  28. BIN locale/cs/LC_MESSAGES/django.mo
  29. +1 −1 locale/cs/LC_MESSAGES/django.po
  30. BIN locale/cy/LC_MESSAGES/django.mo
  31. +1 −1 locale/cy/LC_MESSAGES/django.po
  32. BIN locale/da/LC_MESSAGES/django.mo
  33. +1 −1 locale/da/LC_MESSAGES/django.po
  34. BIN locale/de/LC_MESSAGES/django.mo
  35. +1 −1 locale/de/LC_MESSAGES/django.po
  36. BIN locale/el/LC_MESSAGES/django.mo
  37. +1 −1 locale/el/LC_MESSAGES/django.po
  38. BIN locale/en/LC_MESSAGES/django.mo
  39. +1 −1 locale/en/LC_MESSAGES/django.po
  40. BIN locale/en_GB/LC_MESSAGES/django.mo
  41. +1 −1 locale/en_GB/LC_MESSAGES/django.po
  42. BIN locale/eo/LC_MESSAGES/django.mo
  43. +1 −1 locale/eo/LC_MESSAGES/django.po
  44. BIN locale/es/LC_MESSAGES/django.mo
  45. +1 −1 locale/es/LC_MESSAGES/django.po
  46. BIN locale/es_AR/LC_MESSAGES/django.mo
  47. +1 −1 locale/es_AR/LC_MESSAGES/django.po
  48. BIN locale/es_MX/LC_MESSAGES/django.mo
  49. +1 −1 locale/es_MX/LC_MESSAGES/django.po
  50. BIN locale/et/LC_MESSAGES/django.mo
  51. +1 −1 locale/et/LC_MESSAGES/django.po
  52. BIN locale/eu/LC_MESSAGES/django.mo
  53. +1 −1 locale/eu/LC_MESSAGES/django.po
  54. BIN locale/fa/LC_MESSAGES/django.mo
  55. +1 −1 locale/fa/LC_MESSAGES/django.po
  56. BIN locale/fi/LC_MESSAGES/django.mo
  57. +1 −1 locale/fi/LC_MESSAGES/django.po
  58. BIN locale/fr/LC_MESSAGES/django.mo
  59. +1 −1 locale/fr/LC_MESSAGES/django.po
  60. BIN locale/fy_NL/LC_MESSAGES/django.mo
  61. +1 −1 locale/fy_NL/LC_MESSAGES/django.po
  62. BIN locale/ga/LC_MESSAGES/django.mo
  63. +1 −1 locale/ga/LC_MESSAGES/django.po
  64. BIN locale/gl/LC_MESSAGES/django.mo
  65. +1 −1 locale/gl/LC_MESSAGES/django.po
  66. BIN locale/he/LC_MESSAGES/django.mo
  67. +1 −1 locale/he/LC_MESSAGES/django.po
  68. BIN locale/hi/LC_MESSAGES/django.mo
  69. +1 −1 locale/hi/LC_MESSAGES/django.po
  70. BIN locale/hr/LC_MESSAGES/django.mo
  71. +1 −1 locale/hr/LC_MESSAGES/django.po
  72. BIN locale/hu/LC_MESSAGES/django.mo
  73. +1 −1 locale/hu/LC_MESSAGES/django.po
  74. BIN locale/hy/LC_MESSAGES/django.mo
  75. +1 −1 locale/hy/LC_MESSAGES/django.po
  76. BIN locale/ia/LC_MESSAGES/django.mo
  77. +1 −1 locale/ia/LC_MESSAGES/django.po
  78. BIN locale/id/LC_MESSAGES/django.mo
  79. +1 −1 locale/id/LC_MESSAGES/django.po
  80. BIN locale/is/LC_MESSAGES/django.mo
  81. +1 −1 locale/is/LC_MESSAGES/django.po
  82. BIN locale/it/LC_MESSAGES/django.mo
  83. +1 −1 locale/it/LC_MESSAGES/django.po
  84. BIN locale/ja/LC_MESSAGES/django.mo
  85. +1 −1 locale/ja/LC_MESSAGES/django.po
  86. BIN locale/ka/LC_MESSAGES/django.mo
  87. +1 −1 locale/ka/LC_MESSAGES/django.po
  88. BIN locale/km/LC_MESSAGES/django.mo
  89. +1 −1 locale/km/LC_MESSAGES/django.po
  90. BIN locale/kn/LC_MESSAGES/django.mo
  91. +1 −1 locale/kn/LC_MESSAGES/django.po
  92. BIN locale/ko/LC_MESSAGES/django.mo
  93. +1 −1 locale/ko/LC_MESSAGES/django.po
  94. BIN locale/ky/LC_MESSAGES/django.mo
  95. +1 −1 locale/ky/LC_MESSAGES/django.po
  96. BIN locale/lt/LC_MESSAGES/django.mo
  97. +1 −1 locale/lt/LC_MESSAGES/django.po
  98. BIN locale/lv/LC_MESSAGES/django.mo
  99. +1 −1 locale/lv/LC_MESSAGES/django.po
  100. BIN locale/mk/LC_MESSAGES/django.mo
  101. +1 −1 locale/mk/LC_MESSAGES/django.po
  102. BIN locale/mn/LC_MESSAGES/django.mo
  103. +1 −1 locale/mn/LC_MESSAGES/django.po
  104. BIN locale/ms/LC_MESSAGES/django.mo
  105. +1 −1 locale/ms/LC_MESSAGES/django.po
  106. BIN locale/nb/LC_MESSAGES/django.mo
  107. +1 −1 locale/nb/LC_MESSAGES/django.po
  108. BIN locale/nl/LC_MESSAGES/django.mo
  109. +1 −1 locale/nl/LC_MESSAGES/django.po
  110. BIN locale/nn/LC_MESSAGES/django.mo
  111. +1 −1 locale/nn/LC_MESSAGES/django.po
  112. BIN locale/no/LC_MESSAGES/django.mo
  113. +1 −1 locale/no/LC_MESSAGES/django.po
  114. BIN locale/pl/LC_MESSAGES/django.mo
  115. +1 −1 locale/pl/LC_MESSAGES/django.po
  116. BIN locale/pt/LC_MESSAGES/django.mo
  117. +1 −1 locale/pt/LC_MESSAGES/django.po
  118. BIN locale/pt_BR/LC_MESSAGES/django.mo
  119. +1 −1 locale/pt_BR/LC_MESSAGES/django.po
  120. BIN locale/ro/LC_MESSAGES/django.mo
  121. +1 −1 locale/ro/LC_MESSAGES/django.po
  122. BIN locale/ru/LC_MESSAGES/django.mo
  123. +1 −1 locale/ru/LC_MESSAGES/django.po
  124. BIN locale/sk/LC_MESSAGES/django.mo
  125. +1 −1 locale/sk/LC_MESSAGES/django.po
  126. BIN locale/sl/LC_MESSAGES/django.mo
  127. +1 −1 locale/sl/LC_MESSAGES/django.po
  128. BIN locale/sl_SI/LC_MESSAGES/django.mo
  129. +1 −1 locale/sl_SI/LC_MESSAGES/django.po
  130. BIN locale/sq/LC_MESSAGES/django.mo
  131. +1 −1 locale/sq/LC_MESSAGES/django.po
  132. BIN locale/sr/LC_MESSAGES/django.mo
  133. +1 −1 locale/sr/LC_MESSAGES/django.po
  134. BIN locale/sr_Latn/LC_MESSAGES/django.mo
  135. +1 −1 locale/sr_Latn/LC_MESSAGES/django.po
  136. BIN locale/sv/LC_MESSAGES/django.mo
  137. +1 −1 locale/sv/LC_MESSAGES/django.po
  138. BIN locale/ta/LC_MESSAGES/django.mo
  139. +1 −1 locale/ta/LC_MESSAGES/django.po
  140. BIN locale/te/LC_MESSAGES/django.mo
  141. +1 −1 locale/te/LC_MESSAGES/django.po
  142. BIN locale/th/LC_MESSAGES/django.mo
  143. +1 −1 locale/th/LC_MESSAGES/django.po
  144. BIN locale/tr/LC_MESSAGES/django.mo
  145. +1 −1 locale/tr/LC_MESSAGES/django.po
  146. BIN locale/uk/LC_MESSAGES/django.mo
  147. +1 −1 locale/uk/LC_MESSAGES/django.po
  148. BIN locale/ur/LC_MESSAGES/django.mo
  149. +1 −1 locale/ur/LC_MESSAGES/django.po
  150. BIN locale/vi/LC_MESSAGES/django.mo
  151. +1 −1 locale/vi/LC_MESSAGES/django.po
  152. BIN locale/zh_CN/LC_MESSAGES/django.mo
  153. +1 −1 locale/zh_CN/LC_MESSAGES/django.po
  154. BIN locale/zh_TW/LC_MESSAGES/django.mo
  155. +1 −1 locale/zh_TW/LC_MESSAGES/django.po
  156. +18 −0 media/js/unisubs.site.js
  157. +1 −1 templates/teams/tasks.html
  158. +2 −1 templates/teams/videos-list.html
View
@@ -17,6 +17,7 @@
# http://www.gnu.org/licenses/agpl-3.0.html.
import datetime
import logging
+import csv
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
@@ -37,7 +38,7 @@
from auth.models import CustomUser as User
from auth.providers import get_authentication_provider
from messages import tasks as notifier
-from teams.moderation_const import WAITING_MODERATION, UNMODERATED
+from teams.moderation_const import WAITING_MODERATION, UNMODERATED, APPROVED
from teams.permissions_const import (
TEAM_PERMISSIONS, PROJECT_PERMISSIONS, ROLE_OWNER, ROLE_ADMIN, ROLE_MANAGER,
ROLE_CONTRIBUTOR
@@ -2438,43 +2439,67 @@ def __unicode__(self):
self.start_date.strftime('%Y-%m-%d'),
self.end_date.strftime('%Y-%m-%d'))
- def process(self):
- from teams.moderation_const import APPROVED
- import csv
-
+ def start_datetime(self):
midnight = datetime.time(0, 0, 0)
+ return datetime.datetime.combine(self.start_date, midnight)
+
+ def end_datetime(self):
almost_midnight = datetime.time(23, 59, 59)
- start_date = datetime.datetime.combine(self.start_date, midnight)
- end_date = datetime.datetime.combine(self.end_date, almost_midnight)
+ return datetime.datetime.combine(self.end_date, almost_midnight)
- rows = [['Video title', 'Video URL', 'Video language',
- 'Billable minutes', 'Version created']]
+ def _should_bill(self, language, version, start, end):
+ if not version:
+ return False
- tvs = TeamVideo.objects.filter(team=self.team).order_by('video__title')
+ if version.moderation_status not in [APPROVED, UNMODERATED]:
+ return False
- domain = Site.objects.get_current().domain
- protocol = getattr(settings, 'DEFAULT_PROTOCOL')
- host = '%s://%s' % (protocol, domain)
+ # 97% is done according to our contracts
+ if version.moderation_status == UNMODERATED:
+ if not language.is_complete or language.percent_done < 97:
+ return False
- for tv in tvs:
- languages = tv.video.subtitlelanguage_set.all()
+ if (version.datetime_started <= start or
+ version.datetime_started >= end):
+ return False
- for language in languages:
- v = language.latest_version()
+ return True
- if not v:
- continue
+ def _get_lang_data(self, languages, start_date):
+ lang_data = [(language, language.latest_version()) for language in
+ languages]
- if v.moderation_status not in [APPROVED, UNMODERATED]:
- continue
+ old_version_counter = 1
+
+ for i, data in enumerate(lang_data):
+ lang, ver = data
+
+ if ver and ver.datetime_started < start_date:
+ lang_data.pop(i)
+ old_version_counter += 1
+
+ return lang_data, old_version_counter
- # 97% is done according to our contracts
- if v.moderation_status == UNMODERATED:
- if not language.is_complete or language.percent_done < 97:
- continue
+ def _get_row_data(self, host, header=None):
+ if not header:
+ header = []
- if (v.datetime_started <= start_date) or (
- v.datetime_started >= end_date):
+ rows = [header]
+
+ start_date = self.start_datetime()
+ end_date = self.end_datetime()
+
+ tvs = TeamVideo.objects.filter(team=self.team).order_by('video__title')
+
+ for tv in tvs:
+ languages = tv.video.subtitlelanguage_set.all()
+
+ lang_data, old_version_counter = self._get_lang_data(languages,
+ start_date)
+
+ for language, v in lang_data:
+
+ if not self._should_bill(language, v, start_date, end_date):
continue
subs = v.ordered_subtitles()
@@ -2498,9 +2523,24 @@ def process(self):
host + tv.video.get_absolute_url(),
language.language,
round((end - start) / 60, 2),
- v.datetime_started.strftime("%Y-%m-%d %H:%M:%S")
+ v.datetime_started.strftime("%Y-%m-%d %H:%M:%S"),
+ old_version_counter,
])
+ old_version_counter += 1
+
+ return rows
+
+ def process(self):
+ domain = Site.objects.get_current().domain
+ protocol = getattr(settings, 'DEFAULT_PROTOCOL')
+ host = '%s://%s' % (protocol, domain)
+
+ header = ['Video title', 'Video URL', 'Video language',
+ 'Billable minutes', 'Version created', 'Language number']
+
+ rows = self._get_row_data(host, header)
+
fn = '/tmp/bill-%s-%s-%s.csv' % (self.team.slug, self.start_str,
self.end_str)
@@ -67,8 +67,6 @@ def _urls_for(bundle_name, should_compress):
@register.simple_tag
def include_bundle(bundle_name, should_compress=None):
urls, media_url, bundle_type = _urls_for(bundle_name, should_compress)
-
- print urls
return template.loader.render_to_string("uni_compressor/%s_links.html" % bundle_type,{
"urls": urls,
"adapted_media_url": media_url,
@@ -1,3 +1,4 @@
from test_watch_page import *
from editing import *
from teams import *
+from api_v2 import *
No changes.
@@ -0,0 +1,29 @@
+import os
+import simplejson
+from apps.webdriver_testing.webdriver_base import WebdriverTestCase
+from apps.webdriver_testing import data_helpers
+
+class WebdriverTestCaseLanguagesFetch(WebdriverTestCase):
+ """TestSuite for fetching the list of available languages via the api.
+ """
+
+ def setUp(self):
+ WebdriverTestCase.setUp(self)
+ self.subs_data_dir = os.path.join(os.getcwd(), 'apps',
+ 'webdriver_testing', 'subtitle_data')
+
+ def test_fetch__languages(self):
+ """Fetch the list of available languages.
+ """
+ url_part = 'languages/'
+ status, response = data_helpers.api_get_request(self, url_part)
+ self.assertEqual(200, status)
+ langs = response['languages']
+ lang_checks = {"hr": "Croatian",
+ "zh-cn": "Chinese, Simplified",
+ "zh-hk": "Chinese, Traditional (Hong Kong)",
+ "swa": "Swahili",
+ "es-ar": "Spanish, Argentinian"}
+ for lang_code, lang in lang_checks.iteritems():
+ self.assertEqual(langs[lang_code], lang)
+
Oops, something went wrong.

0 comments on commit 6485a7c

Please sign in to comment.