tables.py 999 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import django_tables2 as tables
  2. from utilities.tables import BaseTable, ButtonsColumn, TagColumn, ToggleColumn
  3. from .models import SecretRole, Secret
  4. #
  5. # Secret roles
  6. #
  7. class SecretRoleTable(BaseTable):
  8. pk = ToggleColumn()
  9. name = tables.LinkColumn()
  10. secret_count = tables.Column(
  11. verbose_name='Secrets'
  12. )
  13. actions = ButtonsColumn(SecretRole, pk_field='slug')
  14. class Meta(BaseTable.Meta):
  15. model = SecretRole
  16. fields = ('pk', 'name', 'secret_count', 'description', 'slug', 'actions')
  17. default_columns = ('pk', 'name', 'secret_count', 'description', 'actions')
  18. #
  19. # Secrets
  20. #
  21. class SecretTable(BaseTable):
  22. pk = ToggleColumn()
  23. device = tables.LinkColumn()
  24. tags = TagColumn(
  25. url_name='secrets:secret_list'
  26. )
  27. class Meta(BaseTable.Meta):
  28. model = Secret
  29. fields = ('pk', 'device', 'role', 'name', 'last_updated', 'hash', 'tags')
  30. default_columns = ('pk', 'device', 'role', 'name', 'last_updated')