Exemple #1
0
class ExperienceForm(forms.Form):
    employer = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'large input-text'}))
    position = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'large input-text'}))
    description = forms.CharField(
        widget=forms.Textarea(attrs={'class': 'post-body'}), required=False)
    start_date = forms.DateTimeField()
    end_date = forms.DateTimeField(required=False)

    def save(self, handler):
        user = handler.get_current_user()
        experience = Experience(employer=self.cleaned_data['employer'],
                                position=self.cleaned_data['position'],
                                description=self.cleaned_data['description'],
                                start_date=self.cleaned_data['start_date'],
                                end_date=self.cleaned_data['end_date'])
        experience.save()
        user.experience.append(experience)
        user.save()
        return experience
Exemple #2
0
class ServicesForm(forms.Form):
    name = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'large input-text'}))

    def save(self, handler):
        user = handler.get_current_user()
        service = Service.objects.get_or_create(
            name=self.cleaned_data['name'])[0]
        service.providers_num += 1
        service.save()
        user.services.append(service)
        user.save()
        return service
Exemple #3
0
class EducationForm(forms.Form):
    university = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'large input-text'}))
    degree = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'large input-text'}))
    major = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'large input-text'}))
    description = forms.CharField(
        widget=forms.Textarea(attrs={'class': 'post-body'}), required=False)
    start_date = forms.DateTimeField()
    end_date = forms.DateTimeField(required=False)

    def save(self, handler):
        user = handler.get_current_user()
        education = Education(university=self.cleaned_data['university'],
                              degree=self.cleaned_data['degree'],
                              major=self.cleaned_data['major'],
                              description=self.cleaned_data['description'],
                              start_date=self.cleaned_data['start_date'],
                              end_date=self.cleaned_data['end_date'])
        education.save()
        user.education.append(education)
        user.save()
        return education
Exemple #4
0
class PasswordRecoveryForm(forms.Form):
    email_or_login = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'large input-text'}),
        label='Please enter your email or password')

    def clean_email_or_login(self):
        data = self.cleaned_data['email_or_login']
        try:
            if '@' in data:
                self.user = User.objects.get(email=data)
            else:
                self.user = User.objects.get(username=data)
        except Exception as e:
            raise forms.ValidationError(
                'A user with such email or username does not exist')
        return self.cleaned_data['email_or_login']

    def save(self):
        return self.user