from django import forms
from django.utils.html import escape

from seahub.profile.models import Profile, DetailedProfile

class ProfileForm(forms.Form):
    nickname = forms.CharField(max_length=64, required=False)
    intro = forms.CharField(max_length=256, required=False)

    def save(self, username):
        nickname = escape(self.cleaned_data['nickname'])
        intro = escape(self.cleaned_data['intro'])
        Profile.objects.add_or_update(username, nickname, intro)

class DetailedProfileForm(ProfileForm):
    department = forms.CharField(max_length=512, required=False)
    telephone = forms.CharField(max_length=100, required=False)

    def save(self, username):
        super(DetailedProfileForm, self).save(username)
        department = escape(self.cleaned_data['department'])
        telephone = escape(self.cleaned_data['telephone'])
        DetailedProfile.objects.add_or_update(username, department, telephone)

from django import forms

from seahub.profile.models import Profile, DetailedProfile

class ProfileForm(forms.Form):
    nickname = forms.CharField(max_length=64, required=False)
    intro = forms.CharField(max_length=256, required=False)

    def save(self, username):
        nickname = self.cleaned_data['nickname']
        intro = self.cleaned_data['intro']
        Profile.objects.add_or_update(username, nickname, intro)

class DetailedProfileForm(ProfileForm):
    department = forms.CharField(max_length=512, required=False)
    telephone = forms.CharField(max_length=100, required=False)

    def save(self, username):
        super(DetailedProfileForm, self).save(username)
        department = self.cleaned_data['department']
        telephone = self.cleaned_data['telephone']
        DetailedProfile.objects.add_or_update(username, department, telephone)

Revert escape nickname, desc, etc in user profile
Revert escape nickname, desc, etc in user profile

  from django import forms
- from django.utils.html import escape
  
  from seahub.profile.models import Profile, DetailedProfile
  
  class ProfileForm(forms.Form):
      nickname = forms.CharField(max_length=64, required=False)
      intro = forms.CharField(max_length=256, required=False)
  
      def save(self, username):
-         nickname = escape(self.cleaned_data['nickname'])
+         nickname = self.cleaned_data['nickname']
-         intro = escape(self.cleaned_data['intro'])
+         intro = self.cleaned_data['intro']
          Profile.objects.add_or_update(username, nickname, intro)
  
  class DetailedProfileForm(ProfileForm):
      department = forms.CharField(max_length=512, required=False)
      telephone = forms.CharField(max_length=100, required=False)
  
      def save(self, username):
          super(DetailedProfileForm, self).save(username)
-         department = escape(self.cleaned_data['department'])
+         department = self.cleaned_data['department']
-         telephone = escape(self.cleaned_data['telephone'])
+         telephone = self.cleaned_data['telephone']
          DetailedProfile.objects.add_or_update(username, department, telephone)
  
Revert escape nickname, desc, etc in user profile
## Code Before:
from django import forms
from django.utils.html import escape

from seahub.profile.models import Profile, DetailedProfile

class ProfileForm(forms.Form):
    nickname = forms.CharField(max_length=64, required=False)
    intro = forms.CharField(max_length=256, required=False)

    def save(self, username):
        nickname = escape(self.cleaned_data['nickname'])
        intro = escape(self.cleaned_data['intro'])
        Profile.objects.add_or_update(username, nickname, intro)

class DetailedProfileForm(ProfileForm):
    department = forms.CharField(max_length=512, required=False)
    telephone = forms.CharField(max_length=100, required=False)

    def save(self, username):
        super(DetailedProfileForm, self).save(username)
        department = escape(self.cleaned_data['department'])
        telephone = escape(self.cleaned_data['telephone'])
        DetailedProfile.objects.add_or_update(username, department, telephone)

## Instruction:
Revert escape nickname, desc, etc in user profile
## Code After:
from django import forms

from seahub.profile.models import Profile, DetailedProfile

class ProfileForm(forms.Form):
    nickname = forms.CharField(max_length=64, required=False)
    intro = forms.CharField(max_length=256, required=False)

    def save(self, username):
        nickname = self.cleaned_data['nickname']
        intro = self.cleaned_data['intro']
        Profile.objects.add_or_update(username, nickname, intro)

class DetailedProfileForm(ProfileForm):
    department = forms.CharField(max_length=512, required=False)
    telephone = forms.CharField(max_length=100, required=False)

    def save(self, username):
        super(DetailedProfileForm, self).save(username)
        department = self.cleaned_data['department']
        telephone = self.cleaned_data['telephone']
        DetailedProfile.objects.add_or_update(username, department, telephone)
