afch-rewrite icon indicating copy to clipboard operation
afch-rewrite copied to clipboard

Submission glitch

Open enterprisey opened this issue 3 years ago • 17 comments

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

enterprisey avatar Oct 23 '21 07:10 enterprisey

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.

primefac avatar Oct 23 '21 08:10 primefac

(thanks primefac!)

enterprisey avatar Oct 25 '21 07:10 enterprisey

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

Prernajha2609 avatar Jan 16 '22 18:01 Prernajha2609

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 avatar Jan 17 '22 06:01 enterprisey

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.

enterprisey avatar Jan 17 '22 06:01 enterprisey

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.

Prernajha2609 avatar Jan 17 '22 12:01 Prernajha2609

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

enterprisey avatar Jan 18 '22 03:01 enterprisey

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

Prernajha2609 avatar Jan 18 '22 07:01 Prernajha2609

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".

enterprisey avatar Jan 18 '22 08:01 enterprisey

Screenshot (340) This is how it looks now.

Prernajha2609 avatar Jan 18 '22 13:01 Prernajha2609

@enterprisey what should I do next?

Prernajha2609 avatar Jan 19 '22 18:01 Prernajha2609

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.

enterprisey avatar Jan 19 '22 22:01 enterprisey

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

Prernajha2609 avatar Jan 21 '22 06:01 Prernajha2609

Screenshot (345)

Prernajha2609 avatar Jan 21 '22 06:01 Prernajha2609

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.

enterprisey avatar Jan 21 '22 06:01 enterprisey

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

Prernajha2609 avatar Jan 21 '22 11:01 Prernajha2609

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.

enterprisey avatar Jan 22 '22 02:01 enterprisey