Repository: dotkom/onlineweb4

Issue:
Marks checkbox in profile is kinda misplaced
Issue from Sverre: På min profil der man skal krysse av for godtatt prikkeregler kan  "prikkeregler" vere en link til https://online.ntnu.no/profile/#marks ?

Either make everything go through the marks tab, or add a link as mentioned above.



Discussion:
The plan is to move this checkbox to the Marks-tab.


Resolving patch:
diff --git a/apps/profiles/forms.py b/apps/profiles/forms.py
--- a/apps/profiles/forms.py
+++ b/apps/profiles/forms.py
@@ -11,9 +11,10 @@ class ProfileForm(forms.ModelForm):
     class Meta:
         model = OnlineUser
 
-        fields = ['nickname', 'website', 'phone_number', 'address', 'zip_code', 'allergies', 'gender', 'mark_rules', ]
+        fields = ['nickname', 'website', 'phone_number', 'address', 'zip_code', 'allergies', 'gender', ]
         widgets = {
             'allergies' : forms.Textarea(attrs={'id' : 'allergies'}),
+            'gender' : forms.Select(attrs={'class' : 'form-control'}),
         }
 
     def clean(self):
diff --git a/apps/profiles/urls.py b/apps/profiles/urls.py
--- a/apps/profiles/urls.py
+++ b/apps/profiles/urls.py
@@ -15,4 +15,5 @@
     url(r'^set_primary/$', 'set_primary', name='profile_set_primary'),
     url(r'^verify_email/$', 'verify_email', name='profile_verify_email'),
     url(r'^save_membership_details/$', 'save_membership_details', name='profile_save_membership_details'),
+    url(r'^update_mark_rules/$', 'update_mark_rules', name='update_mark_rules'),
 )
diff --git a/apps/profiles/views.py b/apps/profiles/views.py
--- a/apps/profiles/views.py
+++ b/apps/profiles/views.py
@@ -64,6 +64,7 @@ def _create_request_dictionary(request):
         'mail_settings' : MailSettingsForm(instance=request.user),
         'new_email' : NewEmailForm(),
         'membership_settings' : MembershipSettingsForm(instance=request.user),
+        'mark_rules_accepted' : request.user.mark_rules,
     }
 
     if request.session.has_key('userprofile_active_tab'):
@@ -104,7 +105,6 @@ def saveUserProfile(request):
 
         user.address = cleaned['address']
         user.allergies = cleaned['allergies']
-        user.mark_rules = cleaned['mark_rules']
         user.nickname = cleaned['nickname']
         user.phone_number = cleaned['phone_number']
         user.website = cleaned['website']
@@ -246,6 +246,27 @@ def savePassword(request):
 
     return redirect("profiles")
 
+
+@login_required
+def update_mark_rules(request):
+    if request.is_ajax():
+        if request.method == 'POST':
+            accepted = request.POST.get('rules_accepted') == "true"
+
+            if accepted:
+                return_status = json.dumps({'message': _(u"Du har valgt å akseptere prikkereglene.")})
+                request.user.mark_rules = True
+                request.user.save()
+            else:
+                return_status = json.dumps({'message': _(u"Du har valgt å ikke akseptere prikkereglene.")})
+                request.user.mark_rules = False
+                request.user.save()
+
+            return HttpResponse(status=212, content=return_status)
+        return HttpResponse(status=405)
+    return HttpResponse(status=404)
+
+
 @login_required
 def add_email(request):
     dict = _create_request_dictionary(request)


Test patch: