Closed Bug 623987 Opened 14 years ago Closed 13 years ago

[traceback] ValueError (from sumo.helpers.datetimeformat) when editing approved translations of unapproved English documents

Categories

(support.mozilla.org :: Knowledge Base Software, task, P2)

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: jsocol, Assigned: paulc)

References

()

Details

Traceback (most recent call last):
...snip...

  File "/data/www/support.mozilla.com/kitsune/apps/wiki/views.py", line 327, in review_revision
    {'revision': rev, 'document': doc, 'form': form})

  File "/data/www/support.mozilla.com/kitsune/vendor/src/jingo/jingo/__init__.py", line 78, in render
    rendered = render_to_string(request, template, context)

  File "/data/www/support.mozilla.com/kitsune/vendor/src/jingo/jingo/__init__.py", line 96, in render_to_string
    return template.render(**get_context())

  File "/usr/lib/python2.6/site-packages/jinja2/environment.py", line 891, in render
    return self.environment.handle_exception(exc_info, True)

  File "/data/www/support.mozilla.com/kitsune/apps/wiki/templates/wiki/review_translation.html", line 7, in top-level template code
    {% set classes = 'review' %}

  File "/data/www/support.mozilla.com/kitsune/apps/wiki/templates/wiki/base.html", line 15, in top-level template code
    {% set top_text = _('Firefox Help') %}

  File "/data/www/support.mozilla.com/kitsune/templates/layout/base.html", line 58, in top-level template code
    {% block content_area %}

  File "/data/www/support.mozilla.com/kitsune/apps/wiki/templates/wiki/base.html", line 34, in block "content_area"
    {% block content %}

  File "/data/www/support.mozilla.com/kitsune/apps/wiki/templates/wiki/review_translation.html", line 46, in block "content"
    <p>{{ _('Revision {id} by {user} on {date}')|f(id=document.parent.current_revision.id, user=document.parent.current_revision.creator, date=datetimeformat(document.parent.current_revision.created, format='longdatetime'))|safe }}</p>

  File "/data/www/support.mozilla.com/kitsune/apps/sumo/helpers.py", line 171, in datetimeformat
    raise ValueError

ValueError


<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'SSID': 'AwDFcikAAAgAi8idTCKxBQGLyJ1MEQAAAAAAAAAAAAAAAADg-wxNAAAAAAAAAAAAAABEAAAARQAAAA',
 'SSID_SUMO': 'AwAp_CkAAAAAHX7cTC5eAAIdftxMyQBFbydNAAAAAAAAAABFbydNAQAwAAAAvQAAAAI',
 'SSLB_SUMO': '1',
 'SSRT': 'RW8nTQE',
 'SSSC_SUMO': '3.G5538440304811597358.201.48.189',
 'WT_FPC': 'id=85.222.10.166-3008287904.30103176:lv=1294397635327:ss=1294395644856',
 '__unam': 'f7237fc-12b301752e2-34b0c798-5',
 'csrftoken': '6983d5ff48ec0286fa492e29b4356e2f',
 'for_browser': 'fx35',
 'for_os': 'win',
 'multidb_pin_writes': 'y',
 's_vi': '',
 'sessionid': 'cb65c3817de54b3eb01625b992910cdf',
 'wtspl': '501910'},
META:{'CSRF_COOKIE': '6983d5ff48ec0286fa492e29b4356e2f',
 'DOCUMENT_ROOT': '/data/www/support.mozilla.com/webroot',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTPS': 'on',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 'HTTP_ACCEPT_CHARSET': 'ISO-8859-2,utf-8;q=0.7,*;q=0.7',
 'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
 'HTTP_ACCEPT_LANGUAGE': 'pl,en-us;q=0.7,en;q=0.3',
 'HTTP_CONNECTION': 'Keep-Alive',
 'HTTP_COOKIE': 'WT_FPC=id=85.222.10.166-3008287904.30103176:lv=1294397635327:ss=1294395644856; __unam=f7237fc-12b301752e2-34b0c798-5; s_vi=[CS]v1|264BC9A805013D84-40000103E00100F9[CE]; SSID=AwDFcikAAAgAi8idTCKxBQGLyJ1MEQAAAAAAAAAAAAAAAADg-wxNAAAAAAAAAAAAAABEAAAARQAAAA; SSRT=4PsMTQA; SSID_SUMO=AwAp_CkAAAAAHX7cTC5eAAIdftxMyQBFbydNAAAAAAAAAABFbydNAQAwAAAAvQAAAAI; SSRT=RW8nTQE; csrftoken=6983d5ff48ec0286fa492e29b4356e2f; wtspl=501910; SSSC_SUMO=3.G5538440304811597358.201.48.189; SSLB_SUMO=1; for_browser=fx35; for_os=win; sessionid=cb65c3817de54b3eb01625b992910cdf; multidb_pin_writes=y',
 'HTTP_HOST': 'support.mozilla.com',
 'HTTP_KEEP_ALIVE': '115',
 'HTTP_REFERER': 'https://support.mozilla.com/pl/kb/new-page-template/history',
 'HTTP_SSLCLIENTCERTSTATUS': 'NoClientCert',
 'HTTP_SSLCLIENTCIPHER': 'SSL_RSA_WITH_RC4_128_SHA, version=SSLv3, bits=128',
 'HTTP_SSLSESSIONID': '10B0B161B4314B197A6F445EC982FC82BA41B816C2CBF72A50D99BB1FFED0103',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2.14pre) Gecko/20110106 Namoroka/3.6.14pre',
 'HTTP_X_CLUSTER_CLIENT_IP': '63.245.213.7',
 'HTTP_X_FORWARDED_FOR': '63.245.213.7',
 'PATH_INFO': u'/pl/kb/new-page-template/review/8044',
 'PATH_TRANSLATED': 'redirect:/k/pl/kb/new-page-template/review/8044/kb/new-page-template/review/8044',
 'QUERY_STRING': '',
 'REDIRECT_HTTPS': 'on',
 'REDIRECT_SCRIPT_URI': 'http://support.mozilla.com/pl/kb/new-page-template/review/8044',
 'REDIRECT_SCRIPT_URL': '/pl/kb/new-page-template/review/8044',
 'REDIRECT_STATUS': '200',
 'REDIRECT_URL': '/pl/kb/new-page-template/review/8044',
 'REDIRECT_is-forwarded': '1',
 'REMOTE_ADDR': '10.2.81.102',
 'REMOTE_PORT': '45863',
 'REQUEST_METHOD': 'GET',
 'REQUEST_URI': '/pl/kb/new-page-template/review/8044',
 'SCRIPT_FILENAME': '/data/www/support.mozilla.com/kitsune/wsgi/kitsune.wsgi',
 'SCRIPT_NAME': u'',
 'SCRIPT_URI': 'http://support.mozilla.com/pl/kb/new-page-template/review/8044',
 'SCRIPT_URL': '/pl/kb/new-page-template/review/8044',
 'SERVER_ADDR': '10.2.81.141',
 'SERVER_ADMIN': 'webmaster@mozilla.com',
 'SERVER_NAME': 'support.mozilla.com',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SIGNATURE': '',
 'SERVER_SOFTWARE': 'Apache',
 'is-forwarded': '1',
 'mod_wsgi.application_group': 'support.mozilla.com|/k',
 'mod_wsgi.callable_object': 'application',
 'mod_wsgi.handler_script': '',
 'mod_wsgi.input_chunked': '0',
 'mod_wsgi.listener_host': '',
 'mod_wsgi.listener_port': '81',
 'mod_wsgi.process_group': 'kitsune-ssl',
 'mod_wsgi.request_handler': 'wsgi-script',
 'mod_wsgi.script_reloading': '1',
 'mod_wsgi.version': (3, 3),
 'platform.name': 'pm-app-sumo02.mozilla.org',
 'wsgi.errors': <mod_wsgi.Log object at 0x2b27487e1d70>,
 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x2b2748968738>,
 'wsgi.input': <mod_wsgi.Input object at 0x2b2748520ab0>,
 'wsgi.loaded': datetime.datetime(2011, 1, 6, 21, 36, 49, 45766),
 'wsgi.multiprocess': True,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'https',
 'wsgi.version': (1, 1)}>
I imagine this is an easy fix, but it turns out those revisions have been deleted.

So I'm grabbing a database from January 8 and hope it's in that one.
Assignee: nobody → paulc
OK, this has pretty complicated STR, but it is a genuine issue.

STR:
1. Create an English document. Do NOT approve any revisions.
2. Translate this document into any other locale.
* Approve a first revision of the *translation* only.
3. Attempt to create another revision of the translation by clicking "Edit this article."

Result: BOOM. Stack trace from above.


We mistakenly assume that a translation with a current revision has a parent with a current revision as well. What would be the best thing to do in this case?
1) Change "Approved English version:" to "Based on English version:" (i.e. use revision.based_on instead of document.parent.current_revision).
2) Fall back to above when no approved English exists.
3) I would expect users to be able to start translating an English document before it's actually approved for the first time, but another solution would also be to disallow translating documents that haven't been approved yet.
4) Something else?

This is not trivial so I'm pushing it out to 2.4.3.
Target Milestone: 2.4.2 → 2.4.3
Summary: [traceback] ValueError (from sumo.helpers.datetimeformat) → [traceback] ValueError (from sumo.helpers.datetimeformat) when editing approved translations of unapproved English documents
https://github.com/jsocol/kitsune/commit/d17dae7f4a4255b01076ffd397c710acb6f1eaf3

QA: see steps from previous comment.
There is also another case this bug fixes, which Ricky found (thanks Ricky!)
1. Create an English document.
2. Reject its first revision
3. Translate this document into any other locale. Approve it.
4. Attempt to create another revision of the translation.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Error & stacktrace generated when trying to translate a document that had it's first revision rejected.
1) create EN doc
2) reject revision
3) click translate article> choose FR

error:  File "/data/www/master.support.mozilla.com/kitsune/apps/wiki/views.py", line 442, in translate
    initial = {'based_on': based_on_rev.id, 'comment': ''}

AttributeError: 'NoneType' object has no attribute 'id'
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Yet another edge case. Now there is a warning when attempting to translate an unreviewed/rejected English document.

https://github.com/jsocol/kitsune/commit/39dfdd81877f8d938b846a83e5bbbb8feba0be59
Status: REOPENED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → FIXED
Verified with multiple revisions in translations based on steps above with no stacktraces.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.