dimagi/commcare-hq — pull request #3413 by briandant (2014-05-14 03:36:55+00:00)
Title: Update error handling for domain copying 

@esoergel and I have been talking through this some, so he could probably help out best.

## Changes I made:
1. Removed check for 'new_project_name', as the form
is handling that, and this should 500 if a dev tries to submit
a post without that.
2. Deleted the if new_domain = None, as the duplication validation
happens on the form.
3. Added the `valid_request` pattern, to avoid multiple invalid round-trips
for the user if they are making two mistakes.
4. Removed check for dom.is_snapshot, as the project_info view has
already checked for that.
5. Removed `eula_confirmed` being passed into form, as that field isn't
on the form, and this is already validated further up in this view.
6. Updated how the errors were being passed back to the user, by using the
`error_message` passed back to the template via the `project_info` view.
7. Moved the required error message onto the form.

## Open Questions
1. Should there be a `domain_type` on this new domain? What is a domain type?
2. Does signing the EULA mean signing the Creative Commons Attribution
thing that pops up, or is this a more general license they've "signed"
somewhere else? If it's here, then we don't need this view to validate that, as
you can't post without clicking that button.
3. Does a check for `dom.is_approved` also ensure that `dom.is_published`?
4. Where do we normally put CSS for page-specific, small changes? I only found the main project
CSS file, so dropped some small stuff in here.

## Stuff to make this better in the future
I'd like to revisit this view after talking through it with some of the
other devs to see if I have any clue what I'm talking about, but for now, the current changes will do some good.

- Put `eula_signed` as a required field (back?) on the DomainRegistrationForm, as a way of ensuring that a domain isn't created without that? If not on the form, then put reusable code in a decorator.
- There's two possible errors in `clean_domain_name`. We should show both
to the user if they are both made.
- The `DomainRegistrationForm` should be passed in to the context of the
`project_info.html` template, so when it's invalid, the user's recently entered
value will show up in the form field ("Wait, there's an error with the way I used dashes?
Wait, what is the last thing I just entered?").
- Make all the validation client side. In addition to all the normal yuminess
of that, the user wouldn't have to accept the agreement every time.
- Better communication about EULA: "You must agree to our End User License
Agreement." Okay, what's that? And where?
- Better handling of unpublished domains. Why did you show me a button for
downloading a thing if it's not published for me to download. *Ain't nobody
got time for that.*