1 from crypt import crypt
2 from django.db import models
3 from django.contrib.messages import add_message
4 from django.utils.timezone import now
5 from .utils import generate_password
8 class FtpUser(models.Model):
9 created_at = models.DateTimeField(auto_now_add=True)
10 last_seen_at = models.DateTimeField(null=True, editable=False)
11 login = models.CharField(max_length=255, unique=True)
12 password = models.CharField(max_length=255, blank=True)
13 password_set_at = models.DateTimeField(null=True, editable=False)
18 def set_password(self, save=True):
19 pwd = generate_password()
20 self.password = crypt(pwd)
21 self.password_set_at = now()