from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from .models import FileModel

class UserCreationForm(UserCreationForm):
    email = forms.EmailField(required=True)
    
    class Meta:
        model = User#myUser
        fields = ("username", "email", "password1", "password2")

    def save(self, commit=True):
        user = super(UserCreationForm, self).save(commit=False)
        user.email = self.cleaned_data["email"]
        if commit:
            user.save()
        return user

class UploadForm(forms.ModelForm):
    class Meta:
        model = FileModel
        exclude = ["user"]

class ShareForm(forms.Form):
    to_username = forms.CharField(label='Shared with', max_length=30)
