Skip to content

Conversation

@lw
Copy link
Member

@lw lw commented Oct 19, 2018

We would mark for translation the message with placeholders (which is correct) but we would look the message up in the catalog after having formatted it, and then of course we wouldn't find any translation.

This also fixes an issue with message extraction.

This fixes #1040 and supersedes #1041.


This change is Reviewable

We would mark for translation the message with placeholders (which is
correct) but we would look the message up in the catalog after having
formatted it, and then of course we wouldn't find any translation.

This also fixes an issue with message extraction.
@lw lw requested a review from stefano-maggiolo October 19, 2018 04:00
@codecov
Copy link

codecov bot commented Oct 19, 2018

Codecov Report

Merging #1046 into master will increase coverage by <.01%.
The diff coverage is 60.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1046      +/-   ##
==========================================
+ Coverage   61.98%   61.98%   +<.01%     
==========================================
  Files         227      227              
  Lines       16405    16421      +16     
==========================================
+ Hits        10169    10179      +10     
- Misses       6236     6242       +6
Flag Coverage Δ
#functionaltests 46.12% <39.47%> (-0.02%) ⬇️
#unittests 43.12% <47.36%> (-0.03%) ⬇️
Impacted Files Coverage Δ
cms/server/contest/handlers/tasksubmission.py 44.44% <0%> (ø) ⬆️
cms/server/contest/handlers/main.py 55.33% <0%> (ø) ⬆️
cms/server/contest/handlers/communication.py 56% <0%> (ø) ⬆️
cms/server/contest/handlers/taskusertest.py 43.63% <0%> (+5.45%) ⬆️
cms/server/contest/communication.py 100% <100%> (ø) ⬆️
cms/server/contest/printing.py 100% <100%> (ø) ⬆️
cms/server/contest/submission/workflow.py 95.8% <57.14%> (-4.2%) ⬇️
cms/server/contest/handlers/contest.py 86.86% <75%> (+0.55%) ⬆️
cms/grading/Job.py 85.78% <0%> (-3.32%) ⬇️
cms/io/PsycoGevent.py 65.71% <0%> (-2.86%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7101adb...57e71fb. Read the comment docs.

Copy link
Member

@stefano-maggiolo stefano-maggiolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 9 of 9 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @lerks)


cms/server/contest/communication.py, line 50 at r1 (raw file):

class UnacceptableQuestion(Exception):

Maybe a cleanup would be to have an intermediate exception type that handles text_params in a standard way?


cms/server/contest/handlers/taskusertest.py, line 141 at r1 (raw file):

        except UnacceptableUserTest as e:
            logger.info("Sent error: `%s' - `%s'", e.subject, e.formatted_text)
            self.notify_error(e.subject, e.text, e.text_params)

Can you avoid changing notify_error and use formatted_text here too?

Copy link
Member Author

@lw lw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @lerks)


cms/server/contest/communication.py, line 50 at r1 (raw file):

Previously, stefano-maggiolo (Stefano Maggiolo) wrote…

Maybe a cleanup would be to have an intermediate exception type that handles text_params in a standard way?

Sure, I can create a common superclass of all these exceptions that defines the __init__ method and the formatted_text property. Where should I put it? It would be nice to have it in the same file as add_notification, notify_error, etc... but that would create a circular dependency (I think). cms/server/contest/__init__.py could work but we don't like putting code in __init__ files, do we? Should I create a new file, say cms/server/contest/util.py, just for this?


cms/server/contest/handlers/taskusertest.py, line 141 at r1 (raw file):

Previously, stefano-maggiolo (Stefano Maggiolo) wrote…

Can you avoid changing notify_error and use formatted_text here too?

I don't see what you mean. formatted_text is untranslated: if we pass it to notify_error then it would need to be de-formatted in order to find its translation. We need to pass to notify_error the two parts (text and params) separate, and then add_notification (called by notify_error) will translate the first and only then put them together. Am I missing something?

Copy link
Member

@stefano-maggiolo stefano-maggiolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


cms/server/contest/communication.py, line 50 at r1 (raw file):

Previously, lerks (Luca Wehrstedt) wrote…

Sure, I can create a common superclass of all these exceptions that defines the __init__ method and the formatted_text property. Where should I put it? It would be nice to have it in the same file as add_notification, notify_error, etc... but that would create a circular dependency (I think). cms/server/contest/__init__.py could work but we don't like putting code in __init__ files, do we? Should I create a new file, say cms/server/contest/util.py, just for this?

The new file sounds good, but thinking about it, it's not so important, feel free to ignore.


cms/server/contest/handlers/taskusertest.py, line 141 at r1 (raw file):

Previously, lerks (Luca Wehrstedt) wrote…

I don't see what you mean. formatted_text is untranslated: if we pass it to notify_error then it would need to be de-formatted in order to find its translation. We need to pass to notify_error the two parts (text and params) separate, and then add_notification (called by notify_error) will translate the first and only then put them together. Am I missing something?

Oh, right. I guess you could cal a e.formatted_translated_text(self._), but the advantage becomes smaller or nonexisting.

@lw lw merged commit fa15aa1 into cms-dev:master Oct 21, 2018
@lw lw deleted the fix_cws_notifs branch October 21, 2018 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Broken "Subject must be at most…" message in .pot file

2 participants