1 from django.conf import settings
2 from django.db import models
3 from django.utils.translation import ugettext_lazy as _
6 class SSHKey(models.Model):
7 user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, verbose_name=_('user'))
8 key = models.TextField(_('key'))
9 comment = models.CharField(_('comment'), max_length=255, blank=True)
10 created_at = models.DateTimeField(_('created at'), auto_now_add=True)
13 ordering = ['created_at']
14 verbose_name = _('SSH key')
15 verbose_name_plural = _('SSH keys')
20 def save(self, *args, **kwargs):
21 self.comment = self.key.rsplit()[-1][:255]
22 return super().save(*args, **kwargs)