models.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """
  2. Models for testing various aspects of the djang.contrib.admindocs app
  3. """
  4. from django.db import models
  5. class Company(models.Model):
  6. name = models.CharField(max_length=200)
  7. class Group(models.Model):
  8. name = models.CharField(max_length=200)
  9. class Family(models.Model):
  10. last_name = models.CharField(max_length=200)
  11. class Person(models.Model):
  12. """
  13. Stores information about a person, related to :model:`myapp.Company`.
  14. **Notes**
  15. Use ``save_changes()`` when saving this object.
  16. ``company``
  17. Field storing :model:`myapp.Company` where the person works.
  18. (DESCRIPTION)
  19. .. raw:: html
  20. :file: admin_docs/evilfile.txt
  21. .. include:: admin_docs/evilfile.txt
  22. """
  23. first_name = models.CharField(max_length=200, help_text="The person's first name")
  24. last_name = models.CharField(max_length=200, help_text="The person's last name")
  25. company = models.ForeignKey(Company, models.CASCADE, help_text="place of work")
  26. family = models.ForeignKey(Family, models.SET_NULL, related_name='+', null=True)
  27. groups = models.ManyToManyField(Group, help_text="has membership")
  28. def _get_full_name(self):
  29. return "%s %s" % (self.first_name, self.last_name)
  30. def add_image(self):
  31. pass
  32. def delete_image(self):
  33. pass
  34. def save_changes(self):
  35. pass
  36. def set_status(self):
  37. pass
  38. def get_full_name(self):
  39. """
  40. Get the full name of the person
  41. """
  42. return self._get_full_name()
  43. def get_status_count(self):
  44. return 0
  45. def get_groups_list(self):
  46. return []