Repository: Cloud-CV/EvalAI
Issue: AttributeError at /api/challenges/challenge/{challenge_pk}/challenge_phase/{pk}
Root cause: Validation Gap

**Steps to Reproduce:**
1. Edit challenge phase details in a challenge
2. Change the date to `--` & submit the form.

**Original message:**
 AttributeError at /api/challenges/challenge/{challenge_pk}/challenge_phase/{pk}


**Expected Message:**
The form should not be submitted & user should know the error.


@RishabhJain2018 Can I work on this issue?

Sure! you can.

Can you please explain where does this issue occur?

I have added the steps to reproduce in the description.

I would like to work on this if no one is working

It seems like @sachinmukherjee is on another issue. @newbazz You can surely start working on this.

I am not able to create a challenge due the fact that I am not able to log in.

I was taking a look and the form is not actually submitted, but it's doing a get request and not taking into consideration the changes made by the form.
If I however change the date to something invalid like 2018-07-32, then I get the error.

The issue seems to be here:

```javascript
vm.editChallengePhase = function(editChallengePhaseForm) {
            if (editChallengePhaseForm) {
                ...
                parameters.callback = {
                    onSuccess: function(response) {
                        var status = response.status;
                        utilities.hideLoader();
                        if (status === 200) {
                            $mdDialog.hide();
                            $rootScope.notify("success", "The challenge phase details are successfully updated!");
                        }
                    },
                    onError: function(response) {
                        utilities.hideLoader();
                        $mdDialog.hide();
                        var error = response.data;
                        $rootScope.notify("error", error);
                    }
                };
                utilities.showLoader();
                utilities.sendRequest(parameters, 'header', 'upload');
            } else {
                parameters.url = 'challenges/challenge/' + vm.challengeId + '/challenge_phase';
                parameters.method = 'GET';
                parameters.data = {};
                parameters.callback = {
                    onSuccess: function(response) {
                        var details = response.data;
                        vm.phases = details;
                        utilities.hideLoader();
                    },
                    onError: function(response) {
                        var error = response.data;
                        utilities.storeData('emailError', error.detail);
                        $state.go('web.permission-denied');
                        utilities.hideLoader();
                    }
                };
                utilities.sendRequest(parameters);
                $mdDialog.hide();
            }
        };
```

If the form has invalid data it just do a get but doesn't let the user know what's going on, however if the form is valid performs the post.

We can give visual feedback to the user when he's entering data in the form. And even if the user submits we can alert him to review the form instead of just doing the get request.

Additionally we should add custom validations for the dates, as for javascrit (2018-07-32) would be valid and represented as (2018-08-01), however python is crashing.

Let me know your thoughts and I can work on it, or if @newbazz is already working on it, he can also take into consideration my comments.

@newbazz Are you still working on it? If not, I would like @bajcmartinez to work on it.

@RishabhJain2018 not sure if @newbazz still working on this, I went ahead and submitted a PR. I found another error which I also fixed on the backend, which refers to modifying an immutable field.
Please let me know your comments or if we can go ahead and merge. Thanks!

Thanks @bajcmartinez for the PR. I'll take a look at it.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


This issue has been automatically closed as there is no further activity. Thank you for your contributions.