<commit_before>from django import forms
from django.contrib.auth import authenticate

from .models import *

class SignInForm(forms.Form):
	username = forms.CharField(max_length=100, label='Username')
	password = forms.CharField(max_length=100, label='Password', widget=forms.PasswordInput)

	def clean(self):
		cleaned_data = super(SignInForm, self).clean()
		user = authenticate(username=cleaned_data.get('username'), password=cleaned_data.get('password'))
		if user is None:
			raise ValidationError('Invalid username or password')

class TopicForm(forms.ModelForm):
	class Meta:
		model = Topic
		fields = ['title', 'tags']

	tags = forms.ModelMultipleChoiceField(queryset=Tag.objects.all())
	first_message = forms.CharField(widget=forms.Textarea)

class NewMessageForm(forms.ModelForm):
	class Meta:
		model = Message
		fields = ['content']

	content = forms.CharField(label="New message", widget=forms.Textarea)

class EditMessageForm(forms.ModelForm):
	class Meta:
		model = Message
		fields = ['content']

	content = forms.CharField(label="Edit message", widget=forms.Textarea)
<commit_msg>Fix bug on sign in page when invalid credentials are given<commit_after>from django import forms
from django.contrib.auth import authenticate

from .models import *

class SignInForm(forms.Form):
	username = forms.CharField(max_length=100, label='Username')
	password = forms.CharField(max_length=100, label='Password', widget=forms.PasswordInput)

	def clean(self):
		cleaned_data = super(SignInForm, self).clean()
		user = authenticate(username=cleaned_data.get('username'), password=cleaned_data.get('password'))
		if user is None:
			raise forms.ValidationError('Invalid username or password')

class TopicForm(forms.ModelForm):
	class Meta:
		model = Topic
		fields = ['title', 'tags']

	tags = forms.ModelMultipleChoiceField(queryset=Tag.objects.all())
	first_message = forms.CharField(widget=forms.Textarea)

class NewMessageForm(forms.ModelForm):
	class Meta:
		model = Message
		fields = ['content']

	content = forms.CharField(label="New message", widget=forms.Textarea)

class EditMessageForm(forms.ModelForm):
	class Meta:
		model = Message
		fields = ['content']

	content = forms.CharField(label="Edit message", widget=forms.Textarea)

{'fraction_non_alphanumeric': 0.11971517578994215, 'fraction_numerical': 0.0053404539385847796, 'mean_word_length': 6.159235668789809, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2845137', 'n_tokens_mistral': 712, 'n_tokens_neox': 668, 'n_words': 158}