wikimedia-gadgets / afc-helper

A tool for reviewing Articles for Creation submissions on the English Wikipedia
https://en.wikipedia.org/wiki/Wikipedia:AFCH
GNU General Public License v3.0
37 stars 80 forks source link

Submission glitch #181

Open enterprisey opened 3 years ago

enterprisey commented 3 years ago

https://en.wikipedia.org/wiki/Wikipedia_talk:WikiProject_Articles_for_creation/Archive_39#AFC_submit_glitch

primefac commented 3 years ago

Just as further explanation, if there is a /draft template on the page, and the user uses the "Submit" option via AFCH, the tool will take the timestamp from the /draft template instead of the current time, which means that the draft ends up in an old (and usually literally "very old").

In other words, AFCH should use the current timestamp and ignore the ts= from the /draft template.

enterprisey commented 3 years ago

(thanks primefac!)

Prernajha2609 commented 2 years ago

@enterprisey I want to work on this issue, can you elaborate on it a little.

enterprisey commented 2 years ago

ok, the relevant function is handleSubmit in submissions.js. In that function you want afchSubmission, which is the submission object, to use the current timestamp and ignore the timestamp that's previously set. You should only need to change one or two lines.

enterprisey commented 2 years ago

I changed the draft in your userspace to show the issue: https://test.wikipedia.org/wiki/User:Prernajha2609/Testing_AFCH. Note that when you try to submit it, the ts= parameter starts with 2019 instead of the current year.

Prernajha2609 commented 2 years ago

function handleSubmit( data ) { var text = data.afchText, submitter = $.Deferred(), submitType = data.submitType;

    if ( submitType === 'other' ) {
        submitter.resolve( data.submitterName );
    } else if ( submitType === 'self' ) {
        submitter.resolve( AFCH.consts.user );
    } else if ( submitType === 'creator' ) {
        afchPage.getCreator().done( function ( user ) {
            submitter.resolve( user );
        } );
    } else {
        // Custom selected submitter
        submitter.resolve( data.submitType );
    }

    submitter.done( function ( submitter ) {
        afchSubmission.setStatus( '', { u: submitter } );

        text.updateAfcTemplates( afchSubmission.makeWikicode() );
        text.cleanUp();

        afchPage.edit( {
            contents: text.get(),
            summary: 'Submitting'
        } );

    } );

}

this is the handleSubmit function but I cannot find anything related to timestamp in this.But in the core.js file there is a function which implements the timestamp.

enterprisey commented 2 years ago

yes, currently there is nothing related to the timestamp; you'll have to add some code that sets the timestamp

Prernajha2609 commented 2 years ago

I added some code but can't see any changes.

enterprisey commented 2 years ago

Make sure your code is setting the right template parameter. I suspect setting ts in the same way that the existing code sets u should work.

I improved the logging display, by the way, so if you want that code, follow the instructions here under "keep your copy of the code up to date".

Prernajha2609 commented 2 years ago

Screenshot (340) This is how it looks now.

Prernajha2609 commented 2 years ago

@enterprisey what should I do next?

enterprisey commented 2 years ago

you will first need to remove the second and third {{AfC submission}} lines in the current version of the draft. to put it into the "draft" status (gray box only). then try to submit the draft using the helper script (not by using the "Submit your draft for review!" button). in the browser console there will be some JSON showing the edit it would have made to the sandbox page. the JSON will contain the new draft text somewhere (which you can recognize because it'll start with {{AFC submission). the |ts= parameter in the new draft text should start with 2022, the current year, instead of some other year. This bug is fixed when the parameter starts with 2022.

Prernajha2609 commented 2 years ago

I am trying to make some changes but they are not visible when I refresh the page.

Prernajha2609 commented 2 years ago

Screenshot (345)

enterprisey commented 2 years ago

You shouldn't have to make any edits to the draft page for this bug, but anyway, you need to click the "Publish Changes" button on the bottom to make an edit.

Prernajha2609 commented 2 years ago

No, I am editing the code but it doesn't work.

enterprisey commented 2 years ago

I can't help without more details, including what you're trying to do, what you've tried, what the current error is (and if there's no error, what you expect to see and what you're getting instead), and what research you've done first. I found a couple of articles on how to ask questions that you may also want to refer to: from ProPublica and from a blog.