Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Project in Admin has "Primary Location" selected for every instance #141

Closed
adriancollier opened this issue Feb 4, 2013 · 11 comments
Closed
Assignees
Milestone

Comments

@adriancollier
Copy link
Contributor

Every time you add a new project location to a project in the Admin, the field for Primary Location is ticked. This results in many locations being marked for Primary Location. Internally for Akvo this is a minor frustration, externally - this is very confusing.

This is illogical functionality.

The first added project should have this field selected, with subsequent additions unselected.

Ideally the field should be selected in the event that there is no existing location with the field selected, but this might be much more complex.

Screen Shot 2013-02-04 at 15 27 11 PM

@zzgvh
Copy link
Contributor

zzgvh commented Feb 4, 2013

It's easy to remove the default checked status. It's at least tricky to make it conditional for only the first one. Also note that (unless there's a bug) the validation when you save a project will protest if there is not exactly one Location with Primary=True.

The reasoning behind setting Primary to true by default is that historically the majority of the projects only have had one location. And so if the box isn't checked you would get a form validation error when you saved the project unless you checked the box by hand.

I'm not disagreeing that it would be nice with the form automatically unchecking the current primary when you select another location as primary, but that would require coding outside what the Django admin allows out of the box, i.e. probably some client side js magic would be needed.

@adriancollier
Copy link
Contributor Author

Could we have a question asking how many projects they have to fill in?

Then we can pre-open the right number of locations and have the first one selected as the primary location.

This could be visualised, if we put a border and different background on the first project, it could be clear this is the primary location.

@zzgvh what do you think?

@zzgvh
Copy link
Contributor

zzgvh commented Jul 9, 2013

It's easy to create a new project form with more than one location form included per default. I'm guessing three might be a good number. Any location forms that don't have any data on posting will be discarded.

I think it's fairly easy to set only one of these location forms to primary=True.

It's also think it's fairly easy to uncheck all other primary location check boxes when you check one. There is code doing similar client side manipulation for the budget and partner type fields, that can be customized for this use case.

I have no idea about the difficulty of highlighting a certain instance of a project location inline form.

@adriancollier
Copy link
Contributor Author

Let's remove Primary location from the UI for Projects and Organisations.

So the first project that is entered is marked at the Primary (in the back end) but nothing changes when shown to a user, so no errors for a missing or duplicate Primaries should be shown.

@adriancollier
Copy link
Contributor Author

We have a solution in the last comment. We should spend no longer than 1 developer days on this solution.

@zzgvh
Copy link
Contributor

zzgvh commented Jun 19, 2014

This solution essentially assigns the "first" location to be primary, right? If so I don't think we even need the BaseLocation.primary field any more. Its raison d'etre was to provide UI for entering the primary loc, but now it's enough with just the foreign key Project.primary_location, no?

@KasperBrandt
Copy link
Contributor

EDIT: Never mind the comment below, you're correct. However, a reason to keep it would be to see what the primary location of a project is without touching the project table. So it might still be handy to keep it in?

Yeah, I thought about that as well. The reason I kept it in was because there might be some projects right now that don't have the 'first' location as primary. Those are kept in place this way, unless the primary location is deleted (then the 'first' location will be appointed as primary).

@zzgvh
Copy link
Contributor

zzgvh commented Jun 23, 2014

I'm not sure. The one place that I can come up with where the primary location is actually used is the map_for_projects API resource and there the query looks like this:

Project.objects.select_related('primary_location', 'primary_location__country').published()

So in essence I can't see a use for BaseLocation.primary field outside of the admin. If it's not used there either I see no reason to keep it.

@KasperBrandt
Copy link
Contributor

Merged in #640

@KasperBrandt
Copy link
Contributor

Test plan

  1. Admin
    GIVEN the project or organisation admin
    WHEN a location is shown
    THEN no primary location checkbox is present
  2. Database
    GIVEN locations in the admin
    WHEN the admin is saved
    THEN the first location should be indicated as primary location in the project / organisation table

@rumca
Copy link
Contributor

rumca commented Jul 2, 2014

Tested on UAT and the primary checkbox has been removed as intended - @KasperBrandt not really sure how to check the database on UAT though?

@MichaelAkvo MichaelAkvo added this to RSR Dec 8, 2022
@MichaelAkvo MichaelAkvo moved this to Done in RSR Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants