Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new3.01 KB

Patch with test coverage.

miro_dietiker’s picture

Status: Needs review » Needs work

OK, now we can submit even if there's no coverage...

+++ b/translators/tmgmt_local/includes/tmgmt_local.plugin.incundefined
@@ -65,6 +69,12 @@ class TMGMTLocalTranslatorUIController extends TMGMTDefaultTranslatorUIControlle
+     $form['allow_all'] = array(
+      '#title' => t('Allow translations for enabled languages even if no translator has the necessary capabilities'),
+      '#type' => 'checkbox',
+      '#default_value' => $job->getSetting('allow_all'),

Possibly the maintainer of the LUI system wants to take controle on that.. and NOT allo this to job creators.
So in this case of a SERVER using LUI accept only jobs that are covered by capabilities.
Or in case of LOCAL translation, we should be able to disallow users to submit such jobs.
I'm not sure if this should even be default...

berdir’s picture

Not sure I follow you ;)

Job creators have no control over this, the admin who configures the translator does. The settings is added to the translator settings, not the checkout settings.

For now, I'm going to assume that these two persons are the same and even if not, it wouldn't change anything about the storage, we'd just need to expose it as a UI to the LUI manager.

The server should respect the languages returned by the translator, then this should just work.

I'm fine with defaulting this to on, but that will conflict with the auto-approve default value patch.

miro_dietiker’s picture

OK, got it for the Local user translator creation. Thought it was a job checkout form...

Regarding server: We can followup on this once the server is ready again with the LUI.

berdir’s picture

Status: Needs work » Needs review

Ah, now I understood what was confusing @cgalli about this.

The job validation considers the capabilities, so you could only submit the job if you had at least one user in your system that was able to translate that language.

The assign list, however, did not. It listed *all* translators, if they were able to translate the job or not. Added test coverage for that and fixed it in an ugly way because the capabilities API is so limited and functionality is mixed between skills and local modules. What's important is the test coverage, because it will allow us to refactor the implementation later on.

berdir’s picture

StatusFileSize
new11.69 KB

Uh, with patch.

cgalli’s picture

Status: Needs review » Needs work
StatusFileSize
new38.49 KB

Cnstalled the patch, works fine. Cannot assign jobs to users without the correct skills anymore, neither in the job checkout pane nor as the manager.

Something has happened to the design (see here)

There is still one case where the skills can be overridden. With the 'Administer translation tasks ' role I can assign jobs to myself, although I do not have the right skills. But that may be acceptable.

cgalli’s picture

Status: Needs work » Reviewed & tested by the community

The broken interface was due to Internet Explorer (see #1889984).

blueminds’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new20.28 KB

Added functionality and test coverage for loading available translators for given tasks based on language skills. Please see the patch.

miro_dietiker’s picture

Status: Needs work » Needs review
+++ b/translators/tmgmt_local/includes/tmgmt_local.pages.incundefined
@@ -350,11 +350,15 @@ function tmgmt_local_translation_form_update_state_ajax($form, &$form_state) {
+    $tasks = explode(',', $tasks);

@@ -350,11 +350,15 @@ function tmgmt_local_translation_form_update_state_ajax($form, &$form_state) {
+    '#options' => tmgmt_local_get_translators_for_tasks($tasks),

I don't like this mix between strings and arrays here. We usually try to be type stable. PHP isn't always that friendly with such cases.

+++ b/translators/tmgmt_local/includes/tmgmt_local.pages.incundefined
+++ b/translators/tmgmt_local/tmgmt_local.testundefined
@@ -165,4 +302,26 @@ class TMGMTLocalTestCase extends TMGMTBaseTestCase {
+  function dtestAllowAll() {

You have a disabled test in this patch :-)

blueminds’s picture

I don't like this mix between strings and arrays here. We usually try to be type stable. PHP isn't always that friendly with such cases.

Totally agree with you, I am just using the design that is there. The tasks get passed via url as comma separated ints. I need to explode that string into array at certain point anyway so that I can use it as parameter for query builder.

You have a disabled test in this patch :-)

This is not mine. I believe the test is not finished anyway.

berdir’s picture

That's my fault, the test should work though.

And yes, the explode is fine, passing a comma separted list through GET is way easier than as an array.

berdir’s picture

+++ b/translators/tmgmt_local/tmgmt_local.moduleundefined
@@ -508,6 +512,32 @@ function tmgmt_local_task_statuses() {
+ * @param array $tasks
+ *   Array of tasks ids.
...
+function tmgmt_local_tasks_languages($tasks) {

Ok.

While it's fine to pass it through as a string, we should be consistent internally and always convert it to an array. If you call explode(',', '1'), it will just return an array with a single value?

Then we can type hint $tasks to array here to be consistent with the @param.

blueminds’s picture

If you call explode(',', '1'), it will just return an array with a single value?

Yes

So you suggest that all calls accepting $tasks should be able to accept string as well as an array?

berdir’s picture

No, the opposite.

The API function only accepts an array and ensures that with (array $tasks). The submit function makes sure that it converts $tasks to an array.

cgalli’s picture

Status: Needs review » Needs work

Installed and tested local-allow-all-1876990-6.patch

Within the local taks it works fine. one can only assign multiple jobs to translators with ALL the neccessary skills.

BUT the job checkout does not seem to work correctly. when checking out a job, the 'assign' dropdown lists translators lacking the needed skills.

New Issue? Or is it covered here?

blueminds’s picture

StatusFileSize
new20.28 KB

Fixed

blueminds’s picture

StatusFileSize
new21.49 KB

sorry, wrong patch

Status: Needs review » Needs work

The last submitted patch, local-allow-all-1876990-8.patch, failed testing.

blueminds’s picture

Status: Needs work » Needs review
StatusFileSize
new21.48 KB

hmm, did diff between branches, apparently did not work.... this one should be okay though

cgalli’s picture

Status: Needs review » Reviewed & tested by the community

Ok, works

berdir’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/includes/tmgmt.entity.incundefined
@@ -845,7 +845,7 @@ class TMGMTJobItem extends Entity {
       $status = $this->getData($key, '#status');
-      if (!$status || $status == TMGMT_DATA_ITEM_STATE_PENDING) {
+      if (!$status || $status == TMGMT_DATA_ITEM_STATE_PENDING || $status == TMGMT_DATA_ITEM_STATE_PENDING) {

This is unrelated.

+++ b/translators/tmgmt_local/includes/tmgmt_local.pages.incundefined
@@ -399,11 +403,15 @@ function tmgmt_local_translation_assign_form_submit($form, &$form_state) {
+  if (strpos($tasks, ',') !== FALSE) {
+    $tasks = explode(',', $tasks);

The check here is not necessary. Make sure it's always an array.

+++ b/translators/tmgmt_local/tmgmt_local.moduleundefined
@@ -508,6 +512,32 @@ function tmgmt_local_task_statuses() {
+  $query->join('tmgmt_job', 'j', 't.tjid = j.tjid');
+  $query->fields('j', array('source_language', 'target_language'));
+  $result = $query->execute()->fetchAll();
+  $languages = array();
+
+  foreach ($result as $row) {
+    if (empty($languages[$row->source_language]) || !in_array($row->target_language, $languages[$row->source_language])) {
+      $languages[$row->source_language][] = $row->target_language;

If you add groupBy()/distinct() to the query then you don't need the condition in the foreach.

That or key by target language as well, then you don't need it either. But groupBy is probably the fastest option.

+++ b/translators/tmgmt_local/tmgmt_local.testundefined
@@ -165,4 +302,26 @@ class TMGMTLocalTestCase extends TMGMTBaseTestCase {
+  function dtestAllowAll() {

Test is still disabled, should not be the case.

I will fix and commit that myself once I find the time but feel free to update if you get to it before I do.

cgalli’s picture

Remark

The patch does work. It sets assignment filters correctly.

But it does not do what the title of the Issue says: Allow submitting of jobs even when the capabilities are not there yet (configurable)

Am I missing something?

berdir’s picture

There should be an option in the translator settings to enable that.

cgalli’s picture

StatusFileSize
new28.27 KB

Hmm, I can't find them (see attachement)

blueminds’s picture

Status: Needs work » Needs review
StatusFileSize
new22.9 KB

Adding patch with implemented comments.

@cgalli - there must be that setting. Please try to reapply the patch, or use the one attached to this comment.

Status: Needs review » Needs work

The last submitted patch, local-allow-all-1876990-10.patch, failed testing.

blueminds’s picture

Status: Needs work » Needs review
StatusFileSize
new22.34 KB

another try...

blueminds’s picture

StatusFileSize
new22.34 KB

Hmm, my last comment did not showed up... the patch is here though:
http://drupal.org/files/local-allow-all-1876990-11.patch

cgalli’s picture

Status: Needs review » Reviewed & tested by the community

NOW it works as advertised :-)

berdir’s picture

Status: Reviewed & tested by the community » Needs work

Commited and pushed.

But I noticed this after I already pushed:

+++ b/translators/tmgmt_local/tmgmt_local.moduleundefined
@@ -508,6 +512,33 @@ function tmgmt_local_task_statuses() {
+  $query->fields('j', array('source_language', 'target_language'));
+  $query->groupBy('target_language');
+  $result = $query->execute()->fetchAll();
+  $languages = array();
+
+  foreach ($result as $row) {
+    if (empty($languages[$row->source_language]) || !in_array($row->target_language, $languages[$row->source_language])) {
+      $languages[$row->source_language][] = $row->target_language;

It needs to group on both target and source language, otherwise it will only return one record per target language.

And the if would then really be unecessary :)