# Path: simone/models.py
# class ImapServer(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     address = models.CharField(max_length=255,null=True)
#     port = models.IntegerField(default=143,null=True)
#     username = models.CharField(max_length=255,null=True)
#     passwd = models.CharField(max_length=255,null=True)
#     ssl = models.BooleanField(default=False)
#     def __str__(self):
#         if not self.address and not self.port and not self.username and not self.passwd:
#             return 'None'
#         if self.ssl:
#             return '%s@imaps://%s:%s' % (self.username, self.address, self.port)
#         return '%s@imap://%s:%s' % (self.username, self.address, self.port)
# 
# class SmtpServer(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     address = models.CharField(max_length=255,null=True)
#     port = models.IntegerField(default=25,null=True)
#     username = models.CharField(max_length=255,null=True)
#     passwd = models.CharField("Password", max_length=255,null=True)
#     def __str__(self):
#         if not self.address and not self.port and not self.username and not self.passwd:
#             return 'None'
#         return '%s@smtp://%s:%s' % (self.username, self.address, self.port)


from django import forms
from .models import ImapServer, SmtpServer

class ImapServerForm(forms.ModelForm):
    class Meta:
        model = ImapServer
        exclude = ['user']
        widgets = {
            'passwd': forms.PasswordInput(),
        }

class SmtpServerForm(forms.ModelForm):
    class Meta:

# Path: simone/models.py
# class ImapServer(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     address = models.CharField(max_length=255,null=True)
#     port = models.IntegerField(default=143,null=True)
#     username = models.CharField(max_length=255,null=True)
#     passwd = models.CharField(max_length=255,null=True)
#     ssl = models.BooleanField(default=False)
#     def __str__(self):
#         if not self.address and not self.port and not self.username and not self.passwd:
#             return 'None'
#         if self.ssl:
#             return '%s@imaps://%s:%s' % (self.username, self.address, self.port)
#         return '%s@imap://%s:%s' % (self.username, self.address, self.port)
# 
# class SmtpServer(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     address = models.CharField(max_length=255,null=True)
#     port = models.IntegerField(default=25,null=True)
#     username = models.CharField(max_length=255,null=True)
#     passwd = models.CharField("Password", max_length=255,null=True)
#     def __str__(self):
#         if not self.address and not self.port and not self.username and not self.passwd:
#             return 'None'
#         return '%s@smtp://%s:%s' % (self.username, self.address, self.port)


# Path: simone/forms.py
from django import forms
from .models import ImapServer, SmtpServer


class ImapServerForm(forms.ModelForm):
    class Meta:
        model = ImapServer
        exclude = ['user']
        widgets = {
            'passwd': forms.PasswordInput(),
        }

class SmtpServerForm(forms.ModelForm):
    class Meta:

        model = SmtpServer