Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission admin always takes last message #170

Closed
gabn88 opened this issue Jan 10, 2016 · 7 comments
Closed

Submission admin always takes last message #170

gabn88 opened this issue Jan 10, 2016 · 7 comments
Labels

Comments

@gabn88
Copy link
Contributor

gabn88 commented Jan 10, 2016

Unless you take the flow with the right upper button, it seems like a submission always take the last message.

Confirmed steps for reproduction

  1. Create two messages belonging to same newsletter, marking one explicitly as last
  2. Create new submission from Newsletter admin (not from Message preview)
  3. Select the newsletter first added
  4. Click 'save and edit'

Expected result

Change form shows last newsletter

Found result

Last added newsletter is selected.

@dokterbob dokterbob added the bug label Jan 10, 2016
@dokterbob dokterbob changed the title It seems like a submission always takes the last message? Submission admin always takes last message Jan 10, 2016
@dokterbob
Copy link
Collaborator

Possibly related to #171

@dokterbob
Copy link
Collaborator

When saving again, the value is preserved.

@dokterbob
Copy link
Collaborator

I still don't know what the cause is, however, the following factors are NOT causing it:

  • The custom SubmissionAdminForm.
  • The custom change_form.html template.
  • The ExtensibleModelAdmin base class.

At this point I am quite clueless as to what might be the cause of this.

dokterbob added a commit that referenced this issue Jan 10, 2016
@dokterbob
Copy link
Collaborator

I've written a regression test but no clue as to the solution. Feel free to pick this one up at any time (but make sure to notify me so we won't accidentily do double work).

@claudep
Copy link
Collaborator

claudep commented Jan 10, 2016

I think the culprit is the Sumission.save() method:

if self.pk is None:
            self.message = Message.get_default()

I think the intent was maybe to test if not self.message?

@dokterbob
Copy link
Collaborator

@claudep Thanks, that's obviously it.

I guess when I wrote it I wanted to give Submission a sensible default. Hence it should have been if not self.message. However, by now (several years later) it is obvious this should end up as a default value for the form.

Ref: https://docs.djangoproject.com/en/1.9/ref/forms/fields/#initial

@gabn88
Copy link
Contributor Author

gabn88 commented Jan 13, 2016

Great that this is resolved so fast! This is why I <3 the Django community!

dsanders11 pushed a commit to dsanders11/django-newsletter that referenced this issue May 2, 2016
dsanders11 pushed a commit to dsanders11/django-newsletter that referenced this issue May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants