Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. class Ticket(models.Model):
  2. user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
  3. designation = models.CharField(max_length=255, blank=True, null=True)
  4.  
  5. def Index(request):
  6. ticket = Ticket.objects.all()
  7. for t in ticket:
  8. id = len(str(t.id))
  9. if id == 1:
  10. t.designation = "#" + str("0000") + str(t.id)
  11. elif id == 2:
  12. t.designation = "#" + str("000") + str(t.id)
  13. elif id == 3:
  14. t.designation = "#" + str("00") + str(t.id)
  15. elif id == 4:
  16. t.designation = "#" + str("0") + str(t.id)
  17. else:
  18. t.designation = "#" + str(t.id)
  19. context = {'ticket':ticket}
  20. return render(request, 'ticketsystem/index.html', context)
  21.  
  22. class Ticket(models.Model):
  23. user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
  24. ticketkennung = models.CharField(max_length=255, blank=True, null=True)
  25.  
  26. def save(self):
  27. id = len(str(id))
  28. if id == 1:
  29. designation = "#" + str("0000") + str(id)
  30. elif id == 2:
  31. designation = "#" + str("000") + str(id)
  32. elif id == 3:
  33. designation = "#" + str("00") + str(id)
  34. elif id == 4:
  35. designation = "#" + str("0") + str(id)
  36. else:
  37. designation = "#" + str(id)
  38. super().save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement