break out transcript approval into separate test

This commit is contained in:
John Bintz 2009-10-26 19:29:46 -04:00
parent 6800ab240a
commit c12ed95806
3 changed files with 199 additions and 76 deletions

View File

@ -762,6 +762,20 @@ class WhatDidTheySayAdmin {
} }
} }
/**
* Approve a transcript.
*/
function _approve_transcript($post_id, $key) {
$approved_transcript_manager = new WDTSApprovedTranscript($post_id);
$queued_transcript_manager = new WDTSQueuedTranscript($post_id);
if (($transcript = $queued_transcript_manager->delete_transcript_by_key($key)) !== false) {
$approved_transcript_manager->save_transcript($transcript);
return true;
}
return false;
}
/** /**
* Handle transcript approval. * Handle transcript approval.
*/ */
@ -769,14 +783,9 @@ class WhatDidTheySayAdmin {
$this->is_ajax = true; $this->is_ajax = true;
if (current_user_can('approve_transcriptions')) { if (current_user_can('approve_transcriptions')) {
$approved_transcript_manager = new WDTSApprovedTranscript($info['post_id']); if (!$this->_approve_transcript($info['post_id'], $info['key'])) {
$queued_transcript_manager = new WDTSQueuedTranscript($info['post_id']); header('HTTP/1.1 500 Internal Server Error');
if (($transcript = $queued_transcript_manager->delete_transcript_by_key($info['key'])) !== false) {
$approved_transcript_manager->save_transcript($transcript);
return;
} }
header('HTTP/1.1 500 Internal Server Error');
return; return;
} }
header('HTTP/1.1 401 Unauthorized'); header('HTTP/1.1 401 Unauthorized');

View File

@ -172,6 +172,38 @@ class WhatDidTheySayAdminTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_result, $admin->_clean_child($nodes)); $this->assertEquals($expected_result, $admin->_clean_child($nodes));
} }
function testApproveTranscript() {
wp_insert_post(array('ID' => 1));
update_post_meta(1, "queued_transcripts", array(
array(
'language' => 'en',
'transcript' => 'This is a test transcript',
'user_id' => 5,
'key' => 1
)
));
$admin = new WhatDidTheySayAdmin();
$this->assertTrue($admin->_approve_transcript(1, 1));
$this->assertEquals(
array(
array(
'language' => 'en',
'transcript' => 'This is a test transcript',
'user_id' => 5,
'key' => 0
)
),
get_post_meta(1, "approved_transcripts", true)
);
$this->assertEquals(
array(), get_post_meta(1, "queued_transcripts", true)
);
}
} }
?> ?>

View File

@ -6,9 +6,9 @@
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: what-did-they-say 0.9.2\n" "Project-Id-Version: what-did-they-say 0.9.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-10-14 22:03-0400\n" "POT-Creation-Date: 2009-10-25 23:07-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -16,11 +16,16 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: what-did-they-say.php:218 #: transcript-filters/comicpress/ComicPressTranscriptBasic.inc:33
#: transcript-filters/comicpress/ComicPressTranscriptBasic.inc:34
msgid "Transcript"
msgstr ""
#: what-did-they-say.php:220
msgid "Edit/Add Transcripts" msgid "Edit/Add Transcripts"
msgstr "" msgstr ""
#: what-did-they-say.php:221 #: what-did-they-say.php:223
#, php-format #, php-format
msgid "%d queued" msgid "%d queued"
msgstr "" msgstr ""
@ -81,16 +86,20 @@ msgstr ""
msgid "Edit Approved Transcripts:" msgid "Edit Approved Transcripts:"
msgstr "" msgstr ""
#: classes/partials/meta-box.inc:37 #: classes/partials/meta-box.inc:37 classes/partials/import-transcripts.inc:23
#: classes/partials/_manage-queued-transcripts.inc:35 #: classes/partials/_manage-queued-transcripts.inc:35
msgid "Language:" msgid "Language:"
msgstr "" msgstr ""
#: classes/partials/meta-box.inc:54 #: classes/partials/meta-box.inc:53
msgid "User to credit: "
msgstr ""
#: classes/partials/meta-box.inc:66
msgid "Update All Transcripts" msgid "Update All Transcripts"
msgstr "" msgstr ""
#: classes/partials/meta-box.inc:58 #: classes/partials/meta-box.inc:70
msgid "" msgid ""
"Uh oh...there's a problem with automatic embedding. Enable &quot;Inject " "Uh oh...there's a problem with automatic embedding. Enable &quot;Inject "
"transcripts at level 100 instead of level 15&quot; on the What Did They " "transcripts at level 100 instead of level 15&quot; on the What Did They "
@ -203,133 +212,137 @@ msgid ""
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:44 #: classes/partials/_default-styles.inc:44
msgid "Give credit to the transcriber on approved transcripts."
msgstr ""
#: classes/partials/_default-styles.inc:52
msgid "" msgid ""
"Allow HTML in transcripts. If disabled, only short codes are allowed, which " "Allow HTML in transcripts. If disabled, only short codes are allowed, which "
"is <strong>recommended</strong>. Script, style, and link tags are " "is <strong>recommended</strong>. Script, style, and link tags are "
"<strong>always</strong> filtered out." "<strong>always</strong> filtered out."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:47 #: classes/partials/_default-styles.inc:55
msgid "By default, transcripts should start hidden on these types of pages:" msgid "By default, transcripts should start hidden on these types of pages:"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:55 #: classes/partials/_default-styles.inc:63
msgid "On the home page" msgid "On the home page"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:63 #: classes/partials/_default-styles.inc:71
msgid "On individual post pages" msgid "On individual post pages"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:69 #: classes/partials/_default-styles.inc:77
msgid "Use the selected transcript filter set:" msgid "Use the selected transcript filter set:"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:71 #: classes/partials/_default-styles.inc:79
#: classes/partials/_change-languages.inc:19 #: classes/partials/_change-languages.inc:19
msgid "(default)" msgid "(default)"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:82 #: classes/partials/_default-styles.inc:90
msgid "" msgid ""
"(Hint: Use the above to preview your filters and style while you work on " "(Hint: Use the above to preview your filters and style while you work on "
"them! The previewer always includes the default stylesheet.)" "them! The previewer always includes the default stylesheet.)"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:84 #: classes/partials/_default-styles.inc:92
msgid "Change default styles" msgid "Change default styles"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:87 #: classes/partials/_default-styles.inc:95
msgid "Transcript Line Breaks" msgid "Transcript Line Breaks"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:89 #: classes/partials/_default-styles.inc:97
msgid "" msgid ""
"If you're using short codes or HTML to construct your transcripts, you don't " "If you're using short codes or HTML to construct your transcripts, you don't "
"need to enable transcript line breaks." "need to enable transcript line breaks."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:91 #: classes/partials/_default-styles.inc:99
msgid "Default CSS Selectors Information" msgid "Default CSS Selectors Information"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:93 #: classes/partials/_default-styles.inc:101
msgid "" msgid ""
"By default, the following CSS selectors are used by <strong>What Did They " "By default, the following CSS selectors are used by <strong>What Did They "
"Say?!?</strong>:" "Say?!?</strong>:"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:96 #: classes/partials/_default-styles.inc:104
msgid "The container for the transcript" msgid "The container for the transcript"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:98 #: classes/partials/_default-styles.inc:106
msgid "Character dialog" msgid "Character dialog"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:100 #: classes/partials/_default-styles.inc:108
msgid "The character's name" msgid "The character's name"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:102 #: classes/partials/_default-styles.inc:110
msgid "" msgid ""
"The direction the characters is speaking in/from (off-stage, to another " "The direction the characters is speaking in/from (off-stage, to another "
"character)" "character)"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:104 #: classes/partials/_default-styles.inc:112
msgid "A scene heading" msgid "A scene heading"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:106 #: classes/partials/_default-styles.inc:114
msgid "Action within a scene" msgid "Action within a scene"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:109 #: classes/partials/_default-styles.inc:117
msgid "Overriding Filters" msgid "Overriding Filters"
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:112 #: classes/partials/_default-styles.inc:120
msgid "" msgid ""
"If you want to override how transcript HTML is structured, create hooks in " "If you want to override how transcript HTML is structured, create hooks in "
"your theme that implement the following filters." "your theme that implement the following filters."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:113 #: classes/partials/_default-styles.inc:121
msgid "" msgid ""
"All of them return the same parameters that are passed in as an array(), " "All of them return the same parameters that are passed in as an array(), "
"with the return <code>$content</code> containing the filter output." "with the return <code>$content</code> containing the filter output."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:118 #: classes/partials/_default-styles.inc:126
msgid "Output <code>$content</code> contains the HTML for dialog blocks." msgid "Output <code>$content</code> contains the HTML for dialog blocks."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:121 #: classes/partials/_default-styles.inc:129
msgid "Output <code>$content</code> contains the HTML for scene action blocks." msgid "Output <code>$content</code> contains the HTML for scene action blocks."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:124 #: classes/partials/_default-styles.inc:132
msgid "" msgid ""
"Ouptut <code>$content</code> contains the HTML for scene heading blocks." "Ouptut <code>$content</code> contains the HTML for scene heading blocks."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:127 #: classes/partials/_default-styles.inc:135
msgid "Output <code>$content</code> contains the HTML for a single transcript." msgid "Output <code>$content</code> contains the HTML for a single transcript."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:130 #: classes/partials/_default-styles.inc:138
msgid "Output <code>$content</code> contains the HTML for a language name." msgid "Output <code>$content</code> contains the HTML for a language name."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:133 #: classes/partials/_default-styles.inc:141
msgid "" msgid ""
"Output <code>$content</code> contains the HTML for all the provided <code>" "Output <code>$content</code> contains the HTML for all the provided <code>"
"$transcripts</code> that match <code>$search_string</code>." "$transcripts</code> that match <code>$search_string</code>."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:136 #: classes/partials/_default-styles.inc:144
#, php-format #, php-format
msgid "" msgid ""
"Output <code>$content</code> contains the sprintf() format string for how " "Output <code>$content</code> contains the sprintf() format string for how "
@ -337,14 +350,14 @@ msgid ""
"code>." "code>."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:139 #: classes/partials/_default-styles.inc:147
msgid "" msgid ""
"Output <code>$content</code> contains three elements: a container (.wdts-" "Output <code>$content</code> contains three elements: a container (.wdts-"
"transcript-opener), and an opener &amp; closer in the container (.wdts-" "transcript-opener), and an opener &amp; closer in the container (.wdts-"
"opener and .wdts-container)." "opener and .wdts-container)."
msgstr "" msgstr ""
#: classes/partials/_default-styles.inc:143 #: classes/partials/_default-styles.inc:151
msgid "" msgid ""
"A filter in your theme that would change the display of langauge names would " "A filter in your theme that would change the display of langauge names would "
"look like the following:" "look like the following:"
@ -446,6 +459,65 @@ msgid ""
"the %s page." "the %s page."
msgstr "" msgstr ""
#: classes/partials/import-transcripts.inc:4
#: classes/WhatDidTheySayAdmin.inc:329 classes/WhatDidTheySayAdmin.inc:330
msgid "Import Transcripts"
msgstr ""
#: classes/partials/import-transcripts.inc:6
msgid ""
"Import transcripts from your current setup into <strong>What Did They Say?!?"
"</strong>"
msgstr ""
#: classes/partials/import-transcripts.inc:7
msgid ""
"Currently, the import supports pulling transcripts from the &quot;"
"transcript&quot; metadata field."
msgstr ""
#: classes/partials/import-transcripts.inc:8
msgid ""
"This field is used by some webcomic themes to store and display transcripts."
msgstr ""
#: classes/partials/import-transcripts.inc:12
msgid "<strong>You have no legacy transcripts!</strong>"
msgstr ""
#: classes/partials/import-transcripts.inc:16
#, php-format
msgid ""
"<strong>You have %d legacy transcripts.</strong< Click the button below to "
"import them into <strong>What Did They Say?!?</strong>"
msgstr ""
#: classes/partials/import-transcripts.inc:17
msgid "<strong>Make sure you've backed up your database first!</strong>"
msgstr ""
#: classes/partials/import-transcripts.inc:18
msgid ""
"<strong>This will also overwrite any WDTS? transcripts that are already in "
"the chosen language for each modified post!</strong>"
msgstr ""
#: classes/partials/import-transcripts.inc:32
msgid "Import transcripts"
msgstr ""
#: classes/partials/import-transcripts.inc:51
msgid "imported..."
msgstr ""
#: classes/partials/import-transcripts.inc:66
msgid "There was a problem during import!"
msgstr ""
#: classes/partials/import-transcripts.inc:73
msgid "Import complete! Total number imported:"
msgstr ""
#: classes/partials/_change-languages.inc:3 classes/partials/admin.inc:7 #: classes/partials/_change-languages.inc:3 classes/partials/admin.inc:7
msgid "Languages" msgid "Languages"
msgstr "" msgstr ""
@ -508,7 +580,7 @@ msgid "Misc. Options"
msgstr "" msgstr ""
#: classes/partials/admin.inc:15 classes/partials/admin.inc:51 #: classes/partials/admin.inc:15 classes/partials/admin.inc:51
#: classes/WhatDidTheySayAdmin.inc:311 classes/WhatDidTheySayAdmin.inc:312 #: classes/WhatDidTheySayAdmin.inc:319 classes/WhatDidTheySayAdmin.inc:320
msgid "What Did They Say?!?" msgid "What Did They Say?!?"
msgstr "" msgstr ""
@ -785,33 +857,33 @@ msgstr ""
msgid "Hey, where are the keys?" msgid "Hey, where are the keys?"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:66 #: classes/WhatDidTheySayAdmin.inc:64
msgid "Submit transcriptions to a post" msgid "Submit transcriptions to a post"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:67 #: classes/WhatDidTheySayAdmin.inc:65
msgid "Approve transcriptions to a post" msgid "Approve transcriptions to a post"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:68 #: classes/WhatDidTheySayAdmin.inc:66
msgid "Change the available languages" msgid "Change the available languages"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:177 #: classes/WhatDidTheySayAdmin.inc:185
msgid "What Did They Say?!? Transcript" msgid "What Did They Say?!? Transcript"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:177 #: classes/WhatDidTheySayAdmin.inc:185
msgid "Show the transcript for the current post." msgid "Show the transcript for the current post."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:326 #: classes/WhatDidTheySayAdmin.inc:345
msgid "" msgid ""
"Welcome to <strong>What Did They Say?!?</strong> To get started, read the " "Welcome to <strong>What Did They Say?!?</strong> To get started, read the "
"<strong>Introduction</strong>, and then <strong>How It Works</strong>." "<strong>Introduction</strong>, and then <strong>How It Works</strong>."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:328 #: classes/WhatDidTheySayAdmin.inc:347
msgid "" msgid ""
"Is <strong>What Did They Say?!?</strong> working out for you? Let John know " "Is <strong>What Did They Say?!?</strong> working out for you? Let John know "
"via email (<a href=\"mailto:john@coswellproductions.com" "via email (<a href=\"mailto:john@coswellproductions.com"
@ -819,97 +891,107 @@ msgid ""
"JohnBintz\">@JohnBintz</a>)." "JohnBintz\">@JohnBintz</a>)."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:349 #: classes/WhatDidTheySayAdmin.inc:372
msgid "Manage Transcripts" msgid "Manage Transcripts"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:393 #: classes/WhatDidTheySayAdmin.inc:416
msgid "Trans" msgid ""
"<span class=\"wdts-posts-queued-icon\">&nbsp;</span> <span class=\"wdts-"
"posts-approved-icon\">&nbsp;</span>"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:406 #: classes/WhatDidTheySayAdmin.inc:426
#, php-format msgid "Queued"
msgid "%s queued"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:599 #: classes/WhatDidTheySayAdmin.inc:426
msgid "Approved"
msgstr ""
#: classes/WhatDidTheySayAdmin.inc:664
msgid "Transcript added to queue." msgid "Transcript added to queue."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:601 #: classes/WhatDidTheySayAdmin.inc:666
msgid "Transcript not added to queue." msgid "Transcript not added to queue."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:677 #: classes/WhatDidTheySayAdmin.inc:753
msgid "Transcripts updated." msgid "Transcripts updated."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:746 #: classes/WhatDidTheySayAdmin.inc:822
msgid "Default styles option updated." msgid "Default styles option updated."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:762 #: classes/WhatDidTheySayAdmin.inc:838
msgid "Insertion level updated." msgid "Insertion level updated."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:780 #: classes/WhatDidTheySayAdmin.inc:856
#, php-format #, php-format
msgid "%s deleted." msgid "%s deleted."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:782 #: classes/WhatDidTheySayAdmin.inc:858
msgid "Language not deleted!" msgid "Language not deleted!"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:789 #: classes/WhatDidTheySayAdmin.inc:865
#, php-format #, php-format
msgid "%s added." msgid "%s added."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:791 #: classes/WhatDidTheySayAdmin.inc:867
msgid "Language not added!" msgid "Language not added!"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:797 #: classes/WhatDidTheySayAdmin.inc:873
#, php-format #, php-format
msgid "%s set as default." msgid "%s set as default."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:799 #: classes/WhatDidTheySayAdmin.inc:875
msgid "Language not set as default!" msgid "Language not set as default!"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:805 #: classes/WhatDidTheySayAdmin.inc:881
#, php-format #, php-format
msgid "%1$s renamed to %2$s." msgid "%1$s renamed to %2$s."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:807 #: classes/WhatDidTheySayAdmin.inc:883
msgid "Language not renamed!" msgid "Language not renamed!"
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:830 #: classes/WhatDidTheySayAdmin.inc:906
msgid "User capabilities updated." msgid "User capabilities updated."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:867 #: classes/WhatDidTheySayAdmin.inc:931
msgid "Per-user permissions updated." msgid "Per-user permissions updated."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:882 #: classes/WhatDidTheySayAdmin.inc:960
msgid "<strong>What Did They Say?!?</strong> options reset." msgid "<strong>What Did They Say?!?</strong> options reset."
msgstr "" msgstr ""
#: classes/WhatDidTheySayAdmin.inc:901 #: classes/WhatDidTheySayAdmin.inc:979
msgid "<strong>What Did They Say?!?</strong> core options changed." msgid "<strong>What Did They Say?!?</strong> core options changed."
msgstr "" msgstr ""
#: classes/WDTSDisplayFilters.inc:52 #: classes/WDTSDisplayFilters.inc:27
#, php-format
msgid "Written by %1$s <strong>%2$s</strong>"
msgstr ""
#: classes/WDTSDisplayFilters.inc:69
#, php-format #, php-format
msgid "Transcript: %s" msgid "Transcript: %s"
msgstr "" msgstr ""
#: classes/WDTSDisplayFilters.inc:81 #: classes/WDTSDisplayFilters.inc:98
#, php-format #, php-format
msgid "%s transcript excerpt:" msgid "%s transcript excerpt:"
msgstr "" msgstr ""