diff --git a/project/accounts/forms.py b/project/accounts/forms.py index af0d18db..723854c1 100644 --- a/project/accounts/forms.py +++ b/project/accounts/forms.py @@ -1,6 +1,7 @@ import re from accounts.models import Profile +from categories.models import Category from django import forms from django.contrib.auth import get_user_model from django.core.files.images import get_image_dimensions @@ -110,6 +111,7 @@ class ProfileEditForm(forms.ModelForm): class Meta: model = Profile + fields = [ "first_name", "last_name", @@ -117,6 +119,7 @@ class Meta: "profile_image", "username", "email", + "categories", ] first_name = forms.CharField(label="First Name", max_length=63, required=False) @@ -125,6 +128,11 @@ class Meta: email = forms.EmailField(label="Email", disabled=True) username = forms.CharField(label="Username", disabled=True) profile_image = forms.ImageField(required=False) + categories = forms.ModelMultipleChoiceField( + queryset=Category.objects.all(), + required=False, + widget=forms.CheckboxSelectMultiple(), + ) class UpdatePassword(forms.ModelForm): diff --git a/project/accounts/templates/accounts/account.html b/project/accounts/templates/accounts/account.html index e9c6602b..9858595d 100644 --- a/project/accounts/templates/accounts/account.html +++ b/project/accounts/templates/accounts/account.html @@ -22,15 +22,15 @@ {% if not profile == request.user.profile %} - {% if profile not in request.user.profile.following.all %} - - follow - - {% else %} - - unfollow - - {% endif %} + {% if profile not in request.user.profile.following.all %} + + follow + + {% else %} + + unfollow + + {% endif %} {% endif %}
@@ -45,6 +45,15 @@
ABOUT ME
{{ profile.about_me }}
+
+
CATEGORIES
+ {% for category in profile.categories.all %} + {% if forloop.last %} +

{{ category }}.

+ {% else %} +

{{ category }},

+ {% endif %} + {% endfor %}
diff --git a/project/accounts/templates/accounts/settings.html b/project/accounts/templates/accounts/settings.html index 8fb956d2..b61d8f00 100644 --- a/project/accounts/templates/accounts/settings.html +++ b/project/accounts/templates/accounts/settings.html @@ -10,75 +10,75 @@ {% block content %}
-
-
-
-
-
- Account Settings -
-
-
- {{form.non_field_errors}} -
- {% csrf_token %} -
-
- {{form.first_name.errors}} - {{form.first_name.label_tag}} - {{form.first_name}} -
-
- {{form.last_name.errors}} - {{form.last_name.label_tag}} - {{form.last_name}} -
-
-
-
- {{form.profile_image.errors}} - {{form.profile_image.label_tag}} - {{form.profile_image}} -
-
-
-
- {{form.username.errors}} - {{form.username.label_tag}} - {{form.username}} -
-
- {{form.email.errors}} - {{form.email.label_tag}} - {{form.email}} -
-
-
-
- {{form.about_me.errors}} - {{form.about_me.label_tag}} - {{form.about_me}} -
-
-
-
- {{form.categories.errors}} - {{form.categories.label_tag}} - {{form.categories}} -
-
-
- {%if not readonly %} - - {% endif%} -
-
-
- -
+
+
+
+
+
+ Account Settings +
+
+
+ {{form.non_field_errors}} +
+ {% csrf_token %} +
+
+ {{form.first_name.errors}} + {{form.first_name.label_tag}} + {{form.first_name}} +
+
+ {{form.last_name.errors}} + {{form.last_name.label_tag}} + {{form.last_name}} +
+
+
+
+ {{form.profile_image.errors}} + {{form.profile_image.label_tag}} + {{form.profile_image}} +
+
+
+
+ {{form.username.errors}} + {{form.username.label_tag}} + {{form.username}}
+
+ {{form.email.errors}} + {{form.email.label_tag}} + {{form.email}} +
+
+
+
+ {{form.about_me.errors}} + {{form.about_me.label_tag}} + {{form.about_me}} +
+
+
+
+ {{form.categories.errors}} + {{form.categories.label_tag}} + {{form.categories}} +
+
+
+ {% if not readonly %} + + {% endif %} +
+
+
+
+
+
{% endblock content %} @@ -86,7 +86,7 @@