<gh_stars>0
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from .models import *
from pagedown.widgets import PagedownWidget

class Subforums(forms.ModelForm):
    class Meta:
        model = Subforum
        fields = [
            'subforum_name',
            'subforum_description'
        ]

class Questions(forms.ModelForm):
    class Meta:
        model = Question
        fields = [
            'ques_text'
        ]        

class Instant_questions(forms.ModelForm):
    
    class Meta:
        model = Question
        fields = [
            'subforum_id',
            'ques_text'
        ]
    

class Answers(forms.ModelForm):
    ans_text = forms.CharField(widget=PagedownWidget)
    class Meta:
        model = Answer
        fields = [
            'ans_text',
        ] 

class Comments(forms.ModelForm):
    class Meta:
        model = Comment
        fields = [
            'comment_text'
        ]

class UserRegisterForm(UserCreationForm):
    email = forms.EmailField(required=True)

    class Meta:
        model = User
        fields = ['username', 'email', '<PASSWORD>', '<PASSWORD>']

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ['age', 'university', 'department']

    # def save(self, commit=True):
    #     user = super(ProfileForm, self).save(commit=False)
    #     user.age = self.cleaned_data['age']
    #     user.university = self.cleaned_data['university']
    #     user.department = self.cleaned_data['department']

    #     if commit:
    #         user.save()

    #     return user    

class EditProfile(UserChangeForm):
    class Meta:
        model = User
        fields = ['email', 'first_name', 'last_name', 'password']

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from .models import *
from pagedown.widgets import PagedownWidget

class Subforums(forms.ModelForm):
    class Meta:
        model = Subforum
        fields = [
            'subforum_name',
            'subforum_description'
        ]

class Questions(forms.ModelForm):
    class Meta:
        model = Question
        fields = [
            'ques_text'
        ]        

class Instant_questions(forms.ModelForm):
    
    class Meta:
        model = Question
        fields = [
            'subforum_id',
            'ques_text'
        ]
    

class Answers(forms.ModelForm):
    ans_text = forms.CharField(widget=PagedownWidget)
    class Meta:
        model = Answer
        fields = [
            'ans_text',
        ] 

class Comments(forms.ModelForm):
    class Meta:
        model = Comment
        fields = [
            'comment_text'
        ]

class UserRegisterForm(UserCreationForm):
    email = forms.EmailField(required=True)

    class Meta:
        model = User
        fields = ['username', 'email', '<PASSWORD>', '<PASSWORD>']

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ['age', 'university', 'department']

    # def save(self, commit=True):
    #     user = super(ProfileForm, self).save(commit=False)
    #     user.age = self.cleaned_data['age']
    #     user.university = self.cleaned_data['university']
    #     user.department = self.cleaned_data['department']

    #     if commit:
    #         user.save()

    #     return user    

class EditProfile(UserChangeForm):
    class Meta:
        model = User
        fields = ['email', 'first_name', 'last_name', 'password']
# def save(self, commit=True): #     user = super(ProfileForm, self).save(commit=False) #     user.age = self.cleaned_data['age'] #     user.university = self.cleaned_data['university'] #     user.department = self.cleaned_data['department'] #     if commit: #         user.save() #     return user