LesFruitsDefendus / saskatoon-ng

The new generation Saskatoon harverst management system
GNU Affero General Public License v3.0
10 stars 24 forks source link

Can't update RequestForParticipation #87

Closed 2ynn closed 3 years ago

2ynn commented 3 years ago

I get alert message "Sorry, this harvest is not open for requests" when trying to update a request for participation: e.g. http://localhost:8000/participation/update/1/ meaning {% harvest.is_open_to_requests == False %} in participation_create.html

I believe {{ harvest }} object doesn't actually gets passed to the form, it looks empty.

Could you please try and reproduce this issue ? Thanks!

tristanlatr commented 3 years ago

Hi, I've created a new Pick on my local instance, set it "Date-scheduled", open another browser, go to the calendar, and when I clicked "send" on the request for participation, I got this error:

Saskatoon version: bc11ac4

Environment:

Request Method: POST
Request URL: http://localhost:8000/participation/create?hid=2

Django Version: 3.2
Python Version: 3.8.10
Installed Applications:
['dal',
 'dal_select2',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'ckeditor',
 'leaflet',
 'sitebase',
 'member',
 'harvest',
 'rest_framework',
 'django_filters',
 'crispy_forms']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/views/generic/edit.py", line 172, in post
    return super().post(request, *args, **kwargs)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/views/generic/edit.py", line 142, in post
    return self.form_valid(form)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/contrib/messages/views.py", line 11, in form_valid
    response = super().form_valid(form)
  File "/Users/tristan/Documents/saskatoon-ng/ve/lib/python3.8/site-packages/django/views/generic/edit.py", line 125, in form_valid
    self.object = form.save()
  File "/Users/tristan/Documents/saskatoon-ng/saskatoon/harvest/forms.py", line 112, in save
    pick_leader_name = harvest_obj.pick_leader.person.first_name

Exception Type: AttributeError at /participation/create
Exception Value: 'NoneType' object has no attribute 'first_name'
2ynn commented 3 years ago

@tristanlatr thanks for your feedback, I'll look into it!

2ynn commented 3 years ago

@tristanlatr were you able to select a pick-leader when you created your new harvest?

tristanlatr commented 3 years ago

were you able to select a pick-leader when you created your new harvest?

Yes

2ynn commented 3 years ago

@tristanlatr I get the same error as you if and only if I don't set a pickleader, which makes sense. I opened new Issue #97

My issue was different. Once I have successfully added a participation request I am trying to edit it (pencil button on the harvest details page ). This is where I get the Sorry, this harvest is not open for requests. You can check the calendar for other harvests. message. I'll dig further into this.

2ynn commented 3 years ago

Ok, I start to wonder if these edit picker request pencils in harvest page should be here in the first place as there is no participation_update.html template that would prefill data for an existing participation request.

The RequestForParticipationUpdateView in harvest/api.py does not pass any data along the form so harvest object is empty and harvest.is_open_to_requests is False in participation_create.html, thus the error message, which makes sense.

Should I create a new participation_update.html template?

I am confused, how does the pick leader accepts a pending participation request?

tristanlatr commented 3 years ago

Here is an extract of the guide, available here: https://github.com/LesFruitsDefendus/guides/blob/master/EN%20Pre-Pick%20Guide%202019.pdf

You can browser the complete set of guides from this repo: https://github.com/LesFruitsDefendus/guides

I don't think the core made any changes since the 2019 version.

by default 2021-06-06 at 6 35 17 PM

2ynn commented 3 years ago

Ok got it, we want something like this: screenshot_2021-06-06_19:56:52

Thanks!

2ynn commented 3 years ago

See new RFPManageForm / template in commit 0a517a004ae5f4e4201cc6fb1842ae6e48a74d08

screenshot_2021-06-07_13:23:47

2ynn commented 3 years ago

Closing this for now, I will edit this form depending on the decision taken about showed_up field in issue #98