Basraah c6118beddf Teamspeak 3 Updates (#741)
* Correct duplicate error and success messages to user

* Read out all buffer bytes before sending command

* Convert ts3 manager to use a single connection

Each instance of the class will now use a single connection and should
be cleanly disconnected when finished.

Compatible with `with` clauses and will automatically disconnect from
the TS3 server when it exits the `with` block.

* Update TS3 manager consumers to use new style

* Update unit tests to use new style manager
2017-02-28 11:28:51 +10:00

17 lines
542 B
Python

from __future__ import unicode_literals
from django import forms
from django.utils.translation import ugettext_lazy as _
from .manager import Teamspeak3Manager
class TeamspeakJoinForm(forms.Form):
username = forms.CharField(widget=forms.HiddenInput())
def clean(self):
with Teamspeak3Manager() as ts3man:
if ts3man._get_userid(self.cleaned_data['username']):
return self.cleaned_data
raise forms.ValidationError(_("Unable to locate user %s on server") % self.cleaned_data['username'])