platform-coop-toolkit / coop-map-directory-index

The Map/Directory/Index component of the Platform Cooperative Development Kit.
https://directory.platform.coop
BSD 3-Clause "New" or "Revised" License
1 stars 3 forks source link

feat: allow individual profile to be edited after creation #126

Closed greatislander closed 4 years ago

greatislander commented 4 years ago

Description

Allows one's individual profile to be edited after it's created.

Steps to test

  1. Check out branch.
  2. Visit your profile
  3. Test both the "Edit Basic Information" and "Edit Overview" links.

Expected behavior: Editing all data works as expected.

Additional information

Not applicable.

Related issues

Not applicable.

erictheise commented 4 years ago

I got this error when trying to save the new Individual profile. Reloaded everything, logged out, logged in. I see the profile I was trying to create so the error occurred after the .save() but clicking on that generates the same error.

Also, I do not see Edit links; are they supposed to be on My Profiles near the Delete or on the actual profile page?

My branch is at 6d64e5b.

Traceback (most recent call last):
  File "/Users/erictheise/Repos/platform-coop-toolkit/coop-map-directory-index/.cmdi/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/erictheise/Repos/platform-coop-toolkit/coop-map-directory-index/.cmdi/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/erictheise/Repos/platform-coop-toolkit/coop-map-directory-index/.cmdi/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/erictheise/Repos/platform-coop-toolkit/coop-map-directory-index/maps/views.py", line 438, in individual_detail
    worked_with_relationship = Relationship.objects.get(name="Worked with")
  File "/Users/erictheise/Repos/platform-coop-toolkit/coop-map-directory-index/.cmdi/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/erictheise/Repos/platform-coop-toolkit/coop-map-directory-index/.cmdi/lib/python3.7/site-packages/django/db/models/query.py", line 417, in get
    self.model._meta.object_name

Exception Type: DoesNotExist at /individuals/1
Exception Value: Relationship matching query does not exist.
greatislander commented 4 years ago

@erictheise Ah, that error is because there is a new relationship ("Worked with") which I'd added locally but not to the demo site: https://demo.directory.platform.coop/admin/mdi/relationship/4/

The links are on the actual profile pages. Because there are two different editing modes ("Edit Basic Information") and ("Edit Overview") we moved them to the profile page itself.

greatislander commented 4 years ago

EDIT: Now working as expected.

@waharnum The issue I was mentioning is as follows:

  1. Social accounts are connected to users through this model: https://github.com/platform-coop-toolkit/coop-map-directory-index/blob/feat/edit-individuals/accounts/models.py#L131-L140
  2. When creating a user, the social networks are edited using this formset factory: https://github.com/platform-coop-toolkit/coop-map-directory-index/blob/feat/edit-individuals/maps/forms.py#L185-L197
  3. When editing the user's overview section (view / form), I'm not quite sure how to:
    • Retrieve existing relationships between user/social networks
    • Display them in a generated formset based on available social networks

I found this article about class-based views with inline formsets but I'm not quite connecting the dots: http://kevindias.com/writing/django-class-based-views-multiple-inline-formsets/

Thanks in advance for any insight you might have here.

greatislander commented 4 years ago

EDIT: Now working as expected.

Making some progress on editable social media in https://github.com/platform-coop-toolkit/coop-map-directory-index/pull/126/commits/844ab69bf1213d5d16eccaeb96d990710ccc73fd but I'm not sure this is the right direction.