prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Updating "My profile" does not save all profile fields
  ## What kind of an issue is this?
  
  - [x] Bug report
  - [ ] Feature request
  
  
  ## What is the expected behaviour?
  Seeing my post number at my [profile overview page](https://online.ntnu.no/profile/overview/)
  
  
  ## What is the current behaviour?
  Seeing `None Ugyldig postnummer` at my [profile overview page](https://online.ntnu.no/profile/overview/)
  
  <!-- if this is a bug report -->
  
  
  ## How do you reproduce this problem? 
  
  - Go to the [profile edit page](https://online.ntnu.no/profile/edit/), write `7050` (or another post number) into the _Postnummer_ field
  - Press _Lagre brukerinformasjon_. No visible errors on page or in browser console, green status box at the top says _"Brukerprofilen din ble endret"_
  - Go to the [profile overview page](https://online.ntnu.no/profile/overview/), look for the _Adresse_. You should now see `None Ugyldig postnummer`.
  
  <!-- if this is a bug report -->
  <!-- provide steps to reproduce this problem, preferably in a bullet point list -->
  
  
  ## Other information
  
  <!-- include screenshots if appropriate -->
  <!-- add labels you see fit. please do not exaggerate. -->
  ### Screenshots
  [Profile edit page:](https://online.ntnu.no/profile/edit/)
  ![image](https://user-images.githubusercontent.com/12127271/32372177-150971b4-c094-11e7-8a05-01eee0603e30.png)
  [Profile overview page:](https://online.ntnu.no/profile/overview/)
  ![image](https://user-images.githubusercontent.com/12127271/32372269-6b2cfdea-c094-11e7-9b39-a459a86451dd.png)
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/profiles/forms.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 import re
  3 
  4 from django import forms
  5 from django.contrib import auth
  6 from django.utils.translation import ugettext as _
  7 
  8 from apps.authentication.models import OnlineUser, Position
  9 from apps.profiles.models import Privacy
  10 
  11 ZIP_CODE_VALIDATION_ERROR = "Postnummer må bestå av fire siffer."
  12 
  13 
  14 class ProfileForm(forms.ModelForm):
  15     class Meta(object):
  16         model = OnlineUser
  17 
  18         fields = [
  19             'nickname',
  20             'website',
  21             'phone_number',
  22             'address',
  23             'zip_code',
  24             'allergies',
  25             'compiled',
  26             'bio',
  27             'gender',
  28             'github',
  29             'linkedin'
  30         ]
  31         widgets = {
  32             'allergies': forms.Textarea(attrs={'id': 'allergies'}),
  33             'gender': forms.Select(attrs={'class': 'form-control', 'id': 'gender'}),
  34             'bio': forms.Textarea(attrs={'id': 'bio'}),
  35             'compiled': forms.CheckboxInput(attrs={'id': 'compiled'}),
  36         }
  37 
  38     def clean_zip_code(self):
  39         zip_code = self.cleaned_data['zip_code']
  40         if zip_code and len(zip_code) != 0 and not re.match(r'\d{4}', zip_code):
  41             self.add_error('zip_code', ZIP_CODE_VALIDATION_ERROR)
  42 
  43 
  44 class PrivacyForm(forms.ModelForm):
  45     class Meta(object):
  46         model = Privacy
  47         exclude = ['user', 'expose_nickname']
  48 
  49 
  50 class MailSettingsForm(forms.ModelForm):
  51     class Meta(object):
  52         model = OnlineUser
  53         fields = ['infomail', ]
  54 
  55 
  56 class PositionForm(forms.ModelForm):
  57     class Meta(object):
  58         model = Position
  59         exclude = ['user']
  60         widgets = {
  61             'committee': forms.Select(attrs={'class': 'form-control'}),
  62             'position': forms.Select(attrs={'class': 'form-control'}),
  63         }
  64 
  65     def clean(self):
  66         super(PositionForm, self).clean()
  67 
  68         range_compiler = re.compile(r'\d{4}-\d{4}')
  69         year_range = self.cleaned_data['period']
  70 
  71         # If it doesn't match the format YYYY-YYYY
  72         if not range_compiler.match(year_range):
  73             self._errors['period'] = self.error_class(
  74                 [_('Feil format. Dobbelsjekk at input er på formatet YYYY-YYYY.')]
  75             )
  76             return self.cleaned_data
  77 
  78         years = year_range.split('-')
  79 
  80         # If somewhat they fucked up input, we don't want None-shit after the split.
  81         if not years[0] or not years[1]:
  82             self._errors['period'] = self.error_class([_('Feil format. Dobbelsjekk input.')])
  83             return self.cleaned_data
  84 
  85         # If first year is larger than latter, or the diff is more than one, fail.
  86         if (int(years[0]) > int(years[1])) or (int(years[1]) - int(years[0])) > 1:
  87             self._errors['period'] = self.error_class([_('Ikke gyldig års-intervall. Bare ett år er tillat.')])
  88 
  89         return self.cleaned_data
  90 
  91 
  92 class MembershipSettingsForm(forms.ModelForm):
  93     def __init__(self, *args, **kwargs):
  94         super(MembershipSettingsForm, self).__init__(*args, **kwargs)
  95         self.fields['started_date'].widget.attrs['class'] = 'hasDatePicker'
  96 
  97     class Meta(object):
  98         model = OnlineUser
  99         fields = ['field_of_study', 'started_date']
  100 
  101         widgets = {
  102             'started_date': forms.TextInput(attrs={'placeholder': 'YYYY-MM-DD'}),
  103         }
  104 
  105 
  106 class InternalServicesForm(forms.Form):
  107     ow4_password = forms.CharField(widget=forms.PasswordInput(), label=_(u"Online passord"))
  108     services_password = forms.CharField(widget=forms.PasswordInput(), label=_(u"Ønsket service passord"))
  109     current_user = None
  110 
  111     def clean(self):
  112         super(InternalServicesForm, self).clean()
  113         if self.is_valid():
  114             cleaned_data = self.cleaned_data
  115 
  116             # User object relation here
  117             user = auth.authenticate(username=self.current_user.username, password=cleaned_data['ow4_password'])
  118 
  119             if user is None or user.id != self.current_user.id:
  120                 self._errors['ow4_password'] = self.error_class([_(u"Passordet er ikke korrekt.")])
  121 
  122             return cleaned_data
  123
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/apps/profiles/forms.py b/apps/profiles/forms.py
  --- a/apps/profiles/forms.py
  +++ b/apps/profiles/forms.py
  @@ -37,9 +37,11 @@
   
       def clean_zip_code(self):
           zip_code = self.cleaned_data['zip_code']
  -        if zip_code and len(zip_code) != 0 and not re.match(r'\d{4}', zip_code):
  +        if not zip_code or not re.match(r'^\d{4}$', zip_code):
               self.add_error('zip_code', ZIP_CODE_VALIDATION_ERROR)
   
  +        return zip_code
  +
   
   class PrivacyForm(forms.ModelForm):
       class Meta(object):
  
verification_info: {"golden_diff": "diff --git a/apps/profiles/forms.py b/apps/profiles/forms.py\n--- a/apps/profiles/forms.py\n+++ b/apps/profiles/forms.py\n@@ -37,9 +37,11 @@\n \n     def clean_zip_code(self):\n         zip_code = self.cleaned_data['zip_code']\n-        if zip_code and len(zip_code) != 0 and not re.match(r'\\d{4}', zip_code):\n+        if not zip_code or not re.match(r'^\\d{4}$', zip_code):\n             self.add_error('zip_code', ZIP_CODE_VALIDATION_ERROR)\n \n+        return zip_code\n+\n \n class PrivacyForm(forms.ModelForm):\n     class Meta(object):\n", "issue": "Updating \"My profile\" does not save all profile fields\n## What kind of an issue is this?\r\n\r\n- [x] Bug report\r\n- [ ] Feature request\r\n\r\n\r\n## What is the expected behaviour?\r\nSeeing my post number at my [profile overview page](https://online.ntnu.no/profile/overview/)\r\n\r\n\r\n## What is the current behaviour?\r\nSeeing `None Ugyldig postnummer` at my [profile overview page](https://online.ntnu.no/profile/overview/)\r\n\r\n<!-- if this is a bug report -->\r\n\r\n\r\n## How do you reproduce this problem? \r\n\r\n- Go to the [profile edit page](https://online.ntnu.no/profile/edit/), write `7050` (or another post number) into the _Postnummer_ field\r\n- Press _Lagre brukerinformasjon_. No visible errors on page or in browser console, green status box at the top says _\"Brukerprofilen din ble endret\"_\r\n- Go to the [profile overview page](https://online.ntnu.no/profile/overview/), look for the _Adresse_. You should now see `None Ugyldig postnummer`.\r\n\r\n<!-- if this is a bug report -->\r\n<!-- provide steps to reproduce this problem, preferably in a bullet point list -->\r\n\r\n\r\n## Other information\r\n\r\n<!-- include screenshots if appropriate -->\r\n<!-- add labels you see fit. please do not exaggerate. -->\r\n### Screenshots\r\n[Profile edit page:](https://online.ntnu.no/profile/edit/)\r\n![image](https://user-images.githubusercontent.com/12127271/32372177-150971b4-c094-11e7-8a05-01eee0603e30.png)\r\n[Profile overview page:](https://online.ntnu.no/profile/overview/)\r\n![image](https://user-images.githubusercontent.com/12127271/32372269-6b2cfdea-c094-11e7-9b39-a459a86451dd.png)\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nimport re\n\nfrom django import forms\nfrom django.contrib import auth\nfrom django.utils.translation import ugettext as _\n\nfrom apps.authentication.models import OnlineUser, Position\nfrom apps.profiles.models import Privacy\n\nZIP_CODE_VALIDATION_ERROR = \"Postnummer m\u00e5 best\u00e5 av fire siffer.\"\n\n\nclass ProfileForm(forms.ModelForm):\n    class Meta(object):\n        model = OnlineUser\n\n        fields = [\n            'nickname',\n            'website',\n            'phone_number',\n            'address',\n            'zip_code',\n            'allergies',\n            'compiled',\n            'bio',\n            'gender',\n            'github',\n            'linkedin'\n        ]\n        widgets = {\n            'allergies': forms.Textarea(attrs={'id': 'allergies'}),\n            'gender': forms.Select(attrs={'class': 'form-control', 'id': 'gender'}),\n            'bio': forms.Textarea(attrs={'id': 'bio'}),\n            'compiled': forms.CheckboxInput(attrs={'id': 'compiled'}),\n        }\n\n    def clean_zip_code(self):\n        zip_code = self.cleaned_data['zip_code']\n        if zip_code and len(zip_code) != 0 and not re.match(r'\\d{4}', zip_code):\n            self.add_error('zip_code', ZIP_CODE_VALIDATION_ERROR)\n\n\nclass PrivacyForm(forms.ModelForm):\n    class Meta(object):\n        model = Privacy\n        exclude = ['user', 'expose_nickname']\n\n\nclass MailSettingsForm(forms.ModelForm):\n    class Meta(object):\n        model = OnlineUser\n        fields = ['infomail', ]\n\n\nclass PositionForm(forms.ModelForm):\n    class Meta(object):\n        model = Position\n        exclude = ['user']\n        widgets = {\n            'committee': forms.Select(attrs={'class': 'form-control'}),\n            'position': forms.Select(attrs={'class': 'form-control'}),\n        }\n\n    def clean(self):\n        super(PositionForm, self).clean()\n\n        range_compiler = re.compile(r'\\d{4}-\\d{4}')\n        year_range = self.cleaned_data['period']\n\n        # If it doesn't match the format YYYY-YYYY\n        if not range_compiler.match(year_range):\n            self._errors['period'] = self.error_class(\n                [_('Feil format. Dobbelsjekk at input er p\u00e5 formatet YYYY-YYYY.')]\n            )\n            return self.cleaned_data\n\n        years = year_range.split('-')\n\n        # If somewhat they fucked up input, we don't want None-shit after the split.\n        if not years[0] or not years[1]:\n            self._errors['period'] = self.error_class([_('Feil format. Dobbelsjekk input.')])\n            return self.cleaned_data\n\n        # If first year is larger than latter, or the diff is more than one, fail.\n        if (int(years[0]) > int(years[1])) or (int(years[1]) - int(years[0])) > 1:\n            self._errors['period'] = self.error_class([_('Ikke gyldig \u00e5rs-intervall. Bare ett \u00e5r er tillat.')])\n\n        return self.cleaned_data\n\n\nclass MembershipSettingsForm(forms.ModelForm):\n    def __init__(self, *args, **kwargs):\n        super(MembershipSettingsForm, self).__init__(*args, **kwargs)\n        self.fields['started_date'].widget.attrs['class'] = 'hasDatePicker'\n\n    class Meta(object):\n        model = OnlineUser\n        fields = ['field_of_study', 'started_date']\n\n        widgets = {\n            'started_date': forms.TextInput(attrs={'placeholder': 'YYYY-MM-DD'}),\n        }\n\n\nclass InternalServicesForm(forms.Form):\n    ow4_password = forms.CharField(widget=forms.PasswordInput(), label=_(u\"Online passord\"))\n    services_password = forms.CharField(widget=forms.PasswordInput(), label=_(u\"\u00d8nsket service passord\"))\n    current_user = None\n\n    def clean(self):\n        super(InternalServicesForm, self).clean()\n        if self.is_valid():\n            cleaned_data = self.cleaned_data\n\n            # User object relation here\n            user = auth.authenticate(username=self.current_user.username, password=cleaned_data['ow4_password'])\n\n            if user is None or user.id != self.current_user.id:\n                self._errors['ow4_password'] = self.error_class([_(u\"Passordet er ikke korrekt.\")])\n\n            return cleaned_data\n", "path": "apps/profiles/forms.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nimport re\n\nfrom django import forms\nfrom django.contrib import auth\nfrom django.utils.translation import ugettext as _\n\nfrom apps.authentication.models import OnlineUser, Position\nfrom apps.profiles.models import Privacy\n\nZIP_CODE_VALIDATION_ERROR = \"Postnummer m\u00e5 best\u00e5 av fire siffer.\"\n\n\nclass ProfileForm(forms.ModelForm):\n    class Meta(object):\n        model = OnlineUser\n\n        fields = [\n            'nickname',\n            'website',\n            'phone_number',\n            'address',\n            'zip_code',\n            'allergies',\n            'compiled',\n            'bio',\n            'gender',\n            'github',\n            'linkedin'\n        ]\n        widgets = {\n            'allergies': forms.Textarea(attrs={'id': 'allergies'}),\n            'gender': forms.Select(attrs={'class': 'form-control', 'id': 'gender'}),\n            'bio': forms.Textarea(attrs={'id': 'bio'}),\n            'compiled': forms.CheckboxInput(attrs={'id': 'compiled'}),\n        }\n\n    def clean_zip_code(self):\n        zip_code = self.cleaned_data['zip_code']\n        if not zip_code or not re.match(r'^\\d{4}$', zip_code):\n            self.add_error('zip_code', ZIP_CODE_VALIDATION_ERROR)\n\n        return zip_code\n\n\nclass PrivacyForm(forms.ModelForm):\n    class Meta(object):\n        model = Privacy\n        exclude = ['user', 'expose_nickname']\n\n\nclass MailSettingsForm(forms.ModelForm):\n    class Meta(object):\n        model = OnlineUser\n        fields = ['infomail', ]\n\n\nclass PositionForm(forms.ModelForm):\n    class Meta(object):\n        model = Position\n        exclude = ['user']\n        widgets = {\n            'committee': forms.Select(attrs={'class': 'form-control'}),\n            'position': forms.Select(attrs={'class': 'form-control'}),\n        }\n\n    def clean(self):\n        super(PositionForm, self).clean()\n\n        range_compiler = re.compile(r'\\d{4}-\\d{4}')\n        year_range = self.cleaned_data['period']\n\n        # If it doesn't match the format YYYY-YYYY\n        if not range_compiler.match(year_range):\n            self._errors['period'] = self.error_class(\n                [_('Feil format. Dobbelsjekk at input er p\u00e5 formatet YYYY-YYYY.')]\n            )\n            return self.cleaned_data\n\n        years = year_range.split('-')\n\n        # If somewhat they fucked up input, we don't want None-shit after the split.\n        if not years[0] or not years[1]:\n            self._errors['period'] = self.error_class([_('Feil format. Dobbelsjekk input.')])\n            return self.cleaned_data\n\n        # If first year is larger than latter, or the diff is more than one, fail.\n        if (int(years[0]) > int(years[1])) or (int(years[1]) - int(years[0])) > 1:\n            self._errors['period'] = self.error_class([_('Ikke gyldig \u00e5rs-intervall. Bare ett \u00e5r er tillat.')])\n\n        return self.cleaned_data\n\n\nclass MembershipSettingsForm(forms.ModelForm):\n    def __init__(self, *args, **kwargs):\n        super(MembershipSettingsForm, self).__init__(*args, **kwargs)\n        self.fields['started_date'].widget.attrs['class'] = 'hasDatePicker'\n\n    class Meta(object):\n        model = OnlineUser\n        fields = ['field_of_study', 'started_date']\n\n        widgets = {\n            'started_date': forms.TextInput(attrs={'placeholder': 'YYYY-MM-DD'}),\n        }\n\n\nclass InternalServicesForm(forms.Form):\n    ow4_password = forms.CharField(widget=forms.PasswordInput(), label=_(u\"Online passord\"))\n    services_password = forms.CharField(widget=forms.PasswordInput(), label=_(u\"\u00d8nsket service passord\"))\n    current_user = None\n\n    def clean(self):\n        super(InternalServicesForm, self).clean()\n        if self.is_valid():\n            cleaned_data = self.cleaned_data\n\n            # User object relation here\n            user = auth.authenticate(username=self.current_user.username, password=cleaned_data['ow4_password'])\n\n            if user is None or user.id != self.current_user.id:\n                self._errors['ow4_password'] = self.error_class([_(u\"Passordet er ikke korrekt.\")])\n\n            return cleaned_data\n", "path": "apps/profiles/forms.py"}]}