2011-10-03 16:36:04 +00:00
|
|
|
from django import forms
|
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2011-10-11 17:03:40 +00:00
|
|
|
from decimal import Decimal as D
|
2011-11-15 23:20:29 +00:00
|
|
|
from regluit.core.models import UserProfile, RightsHolder, Claim
|
|
|
|
|
|
|
|
class ClaimForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Claim
|
|
|
|
widgets = { 'user': forms.HiddenInput, 'work': forms.HiddenInput }
|
2011-11-15 04:28:55 +00:00
|
|
|
|
|
|
|
class RightsHolderForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = RightsHolder
|
|
|
|
|
2011-10-03 16:36:04 +00:00
|
|
|
class ProfileForm(forms.ModelForm):
|
2011-11-14 18:23:14 +00:00
|
|
|
clear_facebook=forms.BooleanField(required=False)
|
|
|
|
clear_twitter=forms.BooleanField(required=False)
|
2011-10-03 16:36:04 +00:00
|
|
|
class Meta:
|
|
|
|
model = UserProfile
|
2011-11-14 18:23:14 +00:00
|
|
|
fields = 'tagline', 'librarything_id', 'home_url', 'clear_facebook', 'clear_twitter'
|
2011-10-03 16:36:04 +00:00
|
|
|
widgets = {
|
2011-10-19 07:13:29 +00:00
|
|
|
'tagline': forms.Textarea(attrs={'cols': 35, 'rows': 4}),
|
2011-10-03 16:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class UserData(forms.Form):
|
|
|
|
username = forms.RegexField(
|
|
|
|
label=_("New Username"),
|
|
|
|
max_length=30,
|
|
|
|
regex=r'^[\w.@+-]+$',
|
|
|
|
help_text = _("30 characters or less."),
|
|
|
|
error_messages = {
|
|
|
|
'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def clean_username(self):
|
|
|
|
username = self.data["username"]
|
|
|
|
oldusername = self.data["oldusername"]
|
|
|
|
if username != oldusername:
|
|
|
|
try:
|
|
|
|
User.objects.get(username=username)
|
|
|
|
except User.DoesNotExist:
|
|
|
|
return username
|
|
|
|
raise forms.ValidationError(_("Another user with that username already exists."))
|
2011-10-09 19:17:43 +00:00
|
|
|
raise forms.ValidationError(_("Your username is already "+oldusername))
|
2011-10-11 17:03:40 +00:00
|
|
|
|
|
|
|
class CampaignPledgeForm(forms.Form):
|
2011-11-09 18:05:03 +00:00
|
|
|
preapproval_amount = forms.DecimalField(initial=None, required=True, min_value=D('0.00'), max_value=D('10000.00'), decimal_places=2, label="Pledge Amount")
|
2011-11-01 21:08:09 +00:00
|
|
|
anonymous = forms.BooleanField(required=False, label="Don't display my username in the supporters list")
|
2011-11-01 00:26:05 +00:00
|
|
|
|
|
|
|
class GoodreadsShelfLoadingForm(forms.Form):
|
2011-11-15 20:51:38 +00:00
|
|
|
goodreads_shelf_name_number = forms.CharField(widget=forms.Select(choices=(
|
2011-11-01 00:26:05 +00:00
|
|
|
('all','all'),
|
|
|
|
)))
|
2011-11-16 18:20:10 +00:00
|
|
|
|
|
|
|
class LibraryThingForm(forms.Form):
|
|
|
|
lt_username = forms.CharField(max_length=30, required=True)
|