Repository: CiviWiki/OpenCiviWiki

Issue:
FileError when editing user profile settings
### Description

After registering and filling in my initial profile, I attempt to visit the Settings screen via the user menu (pictured below).

![image](https://user-images.githubusercontent.com/17307/194142702-6e41e2ea-39cc-4298-bf30-37f98835fd99.png)

When I click the "Settings" link, I am taken to the settings page at http://localhost:8000/settings/

The following `FileError` messages are displayed and the settings page looks somewhat broken.

![image](https://user-images.githubusercontent.com/17307/194142426-b67cb95c-6ee5-4b99-93cf-617339fcb15f.png)


### What should have happened?

I expected the settings page to look fairly "clean" and function correctly.

### What browser(s) are you seeing the problem on?

Chrome

### Further details

_No response_
Uncaught TypeError: Cannot read properties of undefined (reading 'profile_image')
### Description

After going to `http://127.0.0.1:8000/profile/<username>/`, this error raises in the frontend:

<img width="639" alt="Screen Shot 2021-11-03 at 20 27 19" src="https://user-images.githubusercontent.com/16780927/140155266-84933975-d5a0-4b2e-836e-af9cbbe39209.png">


Screenshot of this page:

<img width="1428" alt="Screen Shot 2021-11-03 at 20 30 43" src="https://user-images.githubusercontent.com/16780927/140159554-fd013df0-cf3d-41cc-8cf1-28858bffaf5b.png">



Discussion:

@brylie, when I register a new user, the profile page works well without any error.

<img width="1438" alt="Screen Shot 2021-11-03 at 20 32 00" src="https://user-images.githubusercontent.com/16780927/140161953-74dd10b2-f7f9-420e-85d8-43268c55c2fc.png">

In the user account that I received this error creates new threads and civis. I don't think `profile_image` is related to these instance creations but I'm not sure. 

@brylie, could you check whether any error occurs when they visit `profile` page?

Resolving patch:
diff --git a/project/threads/api.py b/project/threads/api.py
--- a/project/threads/api.py
+++ b/project/threads/api.py
@@ -240,12 +240,13 @@ def create_civi(request):
                 if u.username != request.user.username:
                     notify.send(
                         request.user,  # Actor User
-                        recipient=u.user,  # Target User
+                        recipient=u,  # Target User
                         verb="created a new civi",  # Verb
                         action_object=civi,  # Action Object
                         target=civi.thread,  # Target Object
                         popup_string="{user} created a new civi in {thread}".format(
-                            user=request.user.full_name, thread=civi.thread.title
+                            user=request.user.profile.full_name,
+                            thread=civi.thread.title,
                         ),
                         link="/{}/{}".format("thread", thread_id),
                     )
diff --git a/project/threads/models.py b/project/threads/models.py
--- a/project/threads/models.py
+++ b/project/threads/models.py
@@ -112,6 +112,32 @@ def created_date_str(self):
         d = self.created
         return f"{month_name[d.month]} {d.day}, {d.year}"
 
+    @property
+    def solutions(self):
+        voted_solutions = Activity.objects.filter(
+            user=self.author.id, civi__c_type="solution", activity_type__contains="pos"
+        )
+
+        solution_list = []
+        solution_threads = voted_solutions.values("thread__id").distinct()
+        if self.id in solution_threads:
+            solution_civis = voted_solutions.filter(thread=self.id).values_list(
+                "civi__id", flat=True
+            )
+            for civi_id in solution_civis:
+                c = Civi.objects.get(id=civi_id)
+                vote = voted_solutions.get(civi__id=civi_id).activity_type
+                vote_types = {"vote_pos": "Agree", "vote_vpos": "Strongly Agree"}
+                solution_item = {
+                    "id": c.id,
+                    "title": c.title,
+                    "body": c.body,
+                    "user_vote": vote_types.get(vote),
+                }
+                solution_list.append(solution_item)
+
+        return solution_list
+
 
 class CiviManager(models.Manager):
     def summarize(self, civi):


Test patch: