#203 Add __str__ to models
Merged 5 years ago by jflory7. Opened 5 years ago by anasustic.
fedora-commops/ anasustic/fedora-happiness-packets stringforobject  into  master

@@ -106,12 +106,20 @@ 

          send_html_mail(subject, body_txt, body_html, self.recipient_email)

          self.save()

  

+     def __str__(self):

+         """String for representing the Message object (in Admin site etc.)."""

+         return self.identifier

+ 

  

  class BlacklistedEmail(TimeStampedModel):

      email = models.EmailField()

      stripped_email = models.CharField(max_length=255)

      confirmation_ip = models.GenericIPAddressField()

  

+     def __str__(self):

+         """String for representing the BlacklistedEmail object (in Admin site etc.)."""

+         return self.email

+ 

  

  def strip_email(email):

      return re.sub('[^@\w]', '', re.sub('\+\w+', '', email.lower()))

This change adds _str__() to return a human-readable string for the Message and BlacklistedEmail models in models.py.
With this change individual entries for each both models are easily identified in the Django Admin.
The Message entry will return the the message identifier.
The BlacklistedEmail will return the email.
This change addresses the second point in #157.

Metadata Update from @jflory7:
- Pull-request tagged with: PASSED, improvement, needs testing, type - backend, type - summer coding

5 years ago

Metadata Update from @jflory7:
- Pull-request untagged with: needs testing
- Request assigned

5 years ago

Hi @anasustic, simple and straightforward. Looks good to me! I'm merging it. :clapper:

Pull-Request has been merged by jflory7

5 years ago

Great thanks :raised_hands: