Files
django-discord/chat/forms.py
T
biggy 88bdfc797b feat(voice): add WebRTC voice channels with Cloudflare TURN support
Add voice channel functionality with WebRTC peer-to-peer audio:
- Add VoiceSignalingConsumer for WebRTC signaling and peer coordination
- Add GlobalConsumer for real-time presence and voice status updates
- Add voice channel type to Channel model with current_voice_channel tracking on UserProfile
- Add voice controls UI (mute, deafen, disconnect) in status panel
- Add voice member list display in sidebar with avatar support
- Add
2026-05-23 20:56:37 +02:00

42 lines
1.2 KiB
Python

from django import forms
from django.contrib.auth.models import User
from chat.models import UserProfile, Channel
class RegisterForm(forms.Form):
username = forms.CharField(max_length=150)
email = forms.EmailField()
password = forms.CharField(widget=forms.PasswordInput)
def clean_username(self):
username = self.cleaned_data['username']
if User.objects.filter(username=username).exists():
raise forms.ValidationError('Username already taken.')
return username
def clean_email(self):
email = self.cleaned_data['email']
if User.objects.filter(email=email).exists():
raise forms.ValidationError('Email already in use.')
return email
class ProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ['avatar', 'bio']
widgets = {
'bio': forms.Textarea(attrs={'rows': 3}),
}
class ChannelForm(forms.ModelForm):
class Meta:
model = Channel
fields = ['name', 'description', 'channel_type']
class MessageFileForm(forms.Form):
file = forms.FileField(required=False)
content = forms.CharField(required=False, widget=forms.HiddenInput)