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

Communities - communities #3717

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

openbrian
Copy link
Contributor

Microcosms was renamed to communities See #3683 for the PR before this one.

@openbrian openbrian mentioned this pull request Sep 24, 2022
@openbrian
Copy link
Contributor Author

@gravitystorm @tomhughes Can either of you enable workflows for this PR?

@@ -39,6 +39,7 @@ class ClientApplication < ApplicationRecord

validates :key, :presence => true, :uniqueness => true
validates :name, :url, :secret, :presence => true
# TODO: Consider using UrlValidator from validate_url gem.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I've considered this before! But I'd forgotten about that. Unfortunately it won't work. validate_url requires a list of permitted schemes, but for oauth callbacks any scheme needs to be allowed. See perfectline/validates_url#99

I think this comment can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@gravitystorm
Copy link
Collaborator

For those who are interested in this pull request, @openbrian and I had a conversation about it a couple of weeks ago. The next steps involve working to align this with the new osm-community-index based list of communities, including topics such as how we might like to display both lists of communities, and also how to resolve the (inevitable) situation where a community based entirely on the website (i.e. no external presence, just membership etc through these PRs) ends up listed in the OCI, or existing communities listed in OCI also create a community here.

We also covered the need to avoid merge commits, to rebase this PR onto recent master, and to rework the PR to avoid fixup commits (and generally avoid unnecessary complexity in the history and e.g. git blame). These points are also now covered in the Pull Requests section of CONTRIBUTING.md.

@gravitystorm
Copy link
Collaborator

Hi @openbrian - just wondering if you've had any chance to work on this recently, or if you have any updates for us. When we discussed what was needed for reviewing this PR a few months ago, the main thing was to work on reworking the branch so that it doesn't have so many fixup commits.

It'll also need rebasing onto master again, since the (other) communities branch has been merged, and we need to resolve the conflicts with that.

If there's anything I can do to help, please let me know!

@openbrian
Copy link
Contributor Author

@gravitystorm Indeed over the past 2 weekends, I've reduced the number of commits from 106 to about 12. I now consider myself an interactive rebase-a-holic. I'll push soon.

@openbrian
Copy link
Contributor Author

I shuffled a LOT of commits. I've already rebased master and resolved conflicts. All were minor.

I'd like to make sure each one build and tests successfully. I find this helps if we ever need to git-bisecting a bug.

Eventually, I intend to git push --force here. Let me know if that's an issue.

@gravitystorm
Copy link
Collaborator

Eventually, I intend to git push --force here. Let me know if that's an issue.

Force-pushes to PR branches are completely welcome, no issue with that whatsoever.

@openbrian openbrian force-pushed the communities-communities branch 5 times, most recently from 8afa8e6 to 93763d0 Compare February 23, 2023 02:11
@openbrian
Copy link
Contributor Author

Failing here diff -uw db/structure.expected db/structure.actual. I'll have to make sure to get the order of the SQL statement right.

@openbrian openbrian force-pushed the communities-communities branch from 93763d0 to 6097680 Compare March 3, 2023 04:30
@openbrian
Copy link
Contributor Author

Fixed the ordering of statements in db/structure.sql. Will work on other checks next.

@openbrian openbrian force-pushed the communities-communities branch 6 times, most recently from a71d408 to 22c4492 Compare March 4, 2023 19:14
@openbrian openbrian force-pushed the communities-communities branch 4 times, most recently from 38106a3 to 33a56ab Compare April 15, 2023 17:02
@openbrian openbrian force-pushed the communities-communities branch from 5d60113 to 430899f Compare April 19, 2023 03:41
@openbrian openbrian force-pushed the communities-communities branch from 430899f to 2921f5d Compare May 10, 2023 00:45
@openbrian openbrian force-pushed the communities-communities branch from 2921f5d to 2eb53c1 Compare May 25, 2023 18:57
Copy link
Collaborator

@gravitystorm gravitystorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only a partial review, since it's a big PR and I've run out of time today.

A few other thoughts here as a reminder for myself for the next review:

  • Resolve communities vs communities name clash
  • Consider if communities is already overloaded in the wider osm community e.g. community.osm.org etc
  • list of commits still has fixup commits
  • javascript etc unreviewed
  • can this be slimmed down further e.g. move clever sorting to followup PR etc

config/routes.rb Outdated
@@ -147,7 +147,7 @@
get "/help" => "site#help"
get "/about/:about_locale" => "site#about"
get "/about" => "site#about"
get "/communities" => "site#communities"
get "/community_index" => "site#communities"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to think carefully about doing this, since it would break all external links to the existing communities page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Let's look at the dev site when it's up and running to find the best solution.

The thing is communities is a route resource, so it will get a /communities URL. Maybe that can be customized to avoid this collision.

config/routes.rb Outdated
# user nested resources
resources :users, :path => "user", :param => :display_name do
resources :communities, :only => [:index]
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be combined with the existing resources :users statement, so that resources :users isn't defined twice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 109 to 118
def test_edit_get_no_session
# arrange
c = create(:community)
# act
get edit_community_path(c)
# assert
assert_response :redirect
assert_redirected_to login_path(:referer => edit_community_path(c))
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the hundreds of repeated # arrange, # act, # assert comments are helpful - they are just more text to read and maintain (e.g. when refactoring tests).

I suggest removing the # arrange comments entirely, and changing the other two to blank lines. For example:

  def test_edit_get_no_session
    c = create(:community)

    get edit_community_path(c)

    assert_response :redirect
    assert_redirected_to login_path(:referer => edit_community_path(c))
  end

This keeps the readability of having the three sections being distinct from one another, but with less clutter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that. Just to be clear, it is a unit test design pattern that goes back 20 years. http://wiki.c2.com/?ArrangeActAssert

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the pattern is good, full agreement there. But as the link you gave also suggests, please use blank lines rather than comments:

"Each method should group these functional sections, separated by blank lines: "

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


class CommunityLink < ApplicationRecord
belongs_to :community
validates :site, :presence => true, :length => 1..255, :characters => true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From previous review, "site" here is not clear. Perhaps one of: name, label, text.

(You previously suggested "link" but I think that's even more confusing with "link" vs "url"!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"text" - done

label:
community:
description: "Description"
lat: "Latitude"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the model had attributes of "latitude", not "lat"? Same for lon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

submit:
community:
create: "Create Community"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't "Create %{model_name}" the default here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

lib/osm.rb Outdated
@@ -527,4 +527,9 @@ def self.http_client
def self.maxmind_database
@maxmind_database ||= MaxMindDB.new(Settings.maxmind_database) if Settings.key?(:maxmind_database)
end

# Convert any longitude input to the range -180..180.
def self.normalize_longitude(longitude_in)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just longitude since there's no other longitude in this function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -59,6 +71,15 @@ class UserAbilityTest < AbilityTest
assert ability.cannot?(action, Issue), "should not be able to #{action} Issues"
end
end

# This does not take into account object level access control.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: should it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Anyone can create a community. But a community can only be edited by its owner. I've added test cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 4 to 6
lat1 = Random.rand(-90.0..90.0)
lat2 = Random.rand(-90.0..90.0)
lat1, lat2 = lat2, lat1 if lat2 < lat1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more compact version, using sort:

lat1, lat2 = [Random.rand(-90.0..90.0), Random.rand(-90.0..90.0)].sort

To avoid duplicating the random number bit, you can use an Array construction with a block, but it's perhaps less readable? Probably a personal preference between these two.

lat1, lat2 = Array.new(2) { Random.rand(-90.0..90.0) }.sort

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I went with the Array construction with a block.

@openbrian
Copy link
Contributor Author

Thanks for the feedback so far.

@hallahan
Copy link

LGTM!!!

@openbrian openbrian force-pushed the communities-communities branch 6 times, most recently from c7b51f1 to 65caec0 Compare May 31, 2024 01:37
@openbrian
Copy link
Contributor Author

I've removed all references to "microcosm". I've consolidated all commits into 2 commits:

  1. create communities
  2. create community links

Later PRs will have members, events, and rsvps.

@openbrian openbrian force-pushed the communities-communities branch 4 times, most recently from 7c41be5 to 468d58c Compare July 31, 2024 12:42
@openbrian openbrian force-pushed the communities-communities branch 3 times, most recently from a002e2b to c5f7dca Compare August 8, 2024 12:39
@openbrian openbrian requested a review from gravitystorm August 8, 2024 13:10
@openbrian openbrian force-pushed the communities-communities branch 2 times, most recently from 1f84b71 to 9dd48e9 Compare August 9, 2024 02:40
While a community will eventually have multiple organizers, we need at least one person
to be responsible if an issue is raised.

The community has one owner.  In later PRs, there will be multiple members and multiple organizers.
@openbrian openbrian force-pushed the communities-communities branch from 9dd48e9 to 1f59d7c Compare August 9, 2024 14:10
Links must be https.  Add validate_url ruby gem to validate the urls.

Add not null on link site and url.

Add relevant FK.
@openbrian openbrian force-pushed the communities-communities branch from 1f59d7c to 706667e Compare August 9, 2024 15:40
Copy link
Collaborator

@gravitystorm gravitystorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm at a bit of a loss how to approach this review, since the diff is huge (1700+ additions).

So we could do this in two ways - I can go through the details (e.g. <label> should only be used for forms, it shouldn't have custom CSS, the <h1> in communities#index uses lego translations etc) or we can tackle the big picture (e.g. renaming the existing Communities model/controller, whether we want Yet Another OSM Thing Called Communities, etc).

What would be more helpful? Or should I just send you a stream of feedback as I go?

Comment on lines +348 to +351
resources :communities do
resources :community_links, :only => [:create, :index, :new]
end
resources :community_links, :only => [:destroy, :edit, :update]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't :shallow option of resources do the same thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants