Skip to content

Add organizer to meetings and private and transparent#3136

Merged
mrcasals merged 51 commits intomasterfrom
3044_meeting_types
May 9, 2018
Merged

Add organizer to meetings and private and transparent#3136
mrcasals merged 51 commits intomasterfrom
3044_meeting_types

Conversation

@isaacmg410
Copy link
Copy Markdown
Contributor

@isaacmg410 isaacmg410 commented Apr 5, 2018

🎩 What? Why?

This PR adds the type of meetings functionality and the organizer to the meeting.
The types of meetings are not visible on the public side, the markdown is pending.

📌 Related Issues

📋 Subtasks

  • Add CHANGELOG entry
  • Add checkboxes is_private and is_transparent
  • Add Meeting types checkboxes
  • Add Meeting organizer
  • Add organizer migrations
  • Add organizer to frontend
  • Add meetings types to frontend
  • Specs

@ghost ghost assigned isaacmg410 Apr 5, 2018
@ghost ghost added the status: WIP label Apr 5, 2018
@isaacmg410 isaacmg410 changed the title [WIP] Add meeting types selector and organizer to meetings Add meeting types selector and organizer to meetings Apr 6, 2018
@xabier xabier mentioned this pull request Apr 6, 2018
16 tasks
@isaacmg410 isaacmg410 changed the title Add meeting types selector and organizer to meetings [WIP] Add meeting types selector and organizer to meetings Apr 9, 2018
@isaacmg410 isaacmg410 changed the title [WIP] Add meeting types selector and organizer to meetings Add meeting types selector and organizer to meetings Apr 10, 2018
);
},
renderItem: function (item, search) {
let sanitizedSearch = search.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a comment explaining what this Regexp is looking for?

end

def organizers
respond_to do |format|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CodeClimate reports this method as not covered by any test, maybe move this logic to a service object so it can be easily unit-tested?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

controller tests for organizers done

include Decidim::MapHelper

MEETING_PUBLIC_TYPES = %w(public private other).freeze
MEETING_OPEN_TYPES = %w(open close other).freeze
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be closed (note the d)?

title: Close meeting
meeting_copies:
form:
select_open_type: Select an open type
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like these sentences are not very clear, can you ask product for a better sentence? Open/closed are not types of "open", but different levels of accessibility to me 😕

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The related issue has some sentences explaining what "open", "public" and "transparent" concepts mean for a meeting. I'd add this as a help text to the input, at least.

private: private
public: public
meeting_transparent_types:
opaque: opaque
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does "opaque meeting" imply? 😕

@mrcasals
Copy link
Copy Markdown
Contributor

@isaacmg410 can you please add some screenshosts of how this would look?

@isaacmg410
Copy link
Copy Markdown
Contributor Author

@mrcasals we are still working on this, pending to talk with product about how private_meetings should work better.
Any idea @decidim/lot-core ?

@ghost ghost added the status: WIP label Apr 24, 2018
location_hints: @form.location_hints,
services: @form.services_to_persist.map { |service| { "title" => service.title, "description" => service.description } },
component: @meeting.component,
is_private: @form.is_private,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please you private and transparent? See https://github.com/bbatsov/ruby-style-guide#bool-methods-prefix (not sure why Rubocop doesn't complain)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but private is a reserved key, no? so maybe we can use private_meeting. What you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, didn't though of that. It seems it can be used but I'm not sure if there will be a problem. Maybe @deivid-rodriguez knows about ut?

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use private? instead, which should not clash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd say private is a valid method name... I can't think of any ambiguity from using it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is a valid style remark, but in my opinion is ok. If the column name is an adjective, boolean is the only type that makes sense, no? And it's also the style used with other boolean columns. Basically we never use is_ prefixes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually I just read https://stackoverflow.com/questions/16099073/ruby-reserved-class-method-names and it looks like @isaacmg410 is right and we shouldn't do this... For example, if you define a private class method, it makes the private keyword lose its meaning and instead calls the class method... So sorry for the extra friction here Isaac but I think it's probably safer to go back to your original version?

Copy link
Copy Markdown
Contributor Author

@isaacmg410 isaacmg410 Apr 24, 2018

Choose a reason for hiding this comment

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

😕 so.... some possibilities:
is_private
private_meeting
for_only_invited
only_invited

Which of the options do you think is better?
@decidim/lot-core @deivid-rodriguez

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

private_meeting works for me!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

private_meeting looks perfect to me as well! Sorry again @isaacmg410 for the back and forth.

def organizers
respond_to do |format|
format.json do
query = current_organization.users&.order(name: :asc)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If users is an ActiveRecord::Relation you don't need the &

else
query = query.where("name ILIKE ?", "%#{params[:term]}%")
end
render json: query.all.collect { |p| [p.id, p.name, p.nickname] }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe query.pluck(:id, :name, :nickname)?

end

def current_user_can_visit_meeting?
(meeting.try(:is_private?) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding a return unless meeting would prevent all the trys

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, maybe this logic should be inside a method in a Meeting?

end

def show
check_current_user_can_visit_meeting
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this method used elsewhere? If not, consider moving the logic here.

CGI.unescapeHTML html_truncate(description, max_length: max_length, tail: tail)
end

def meeting_type_badge_css_class(type)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please addd some docs?

end
end

def organizers
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of adding a custom action, could you add an OrganizersController with an index action? (scoped to a meeting)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

is this necessary to be scoped to a meeting? if we are returning all the users of the current organization?

Also in accountability there are something similar with proposals and there is created as a custom action.

What is better?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, if it's used somewhere else then no need to scope it to a meeting!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about this? I'm OK with not scoping it to a meeting but I'd create an OrganizersController anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! I create a UsersController to be reusable to other components

public_type_other: :string,
transparent_type: :string,
transparent_type_other: :string,
organizer_id: :integer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will only show the ID, which doesn't provide any info the the user checking the log. Can you make a new ResourcePresenter for the organizer so it's properly displayed?

You can check NewsletterResourcePresenter for example

oriolgual
oriolgual previously approved these changes Apr 26, 2018
@isaacmg410
Copy link
Copy Markdown
Contributor Author

@decidim/lot-core Requested changes applied, can you review it please?

return false if participatory_space.try(:private_space?) && participatory_space.try(:transparent?)
end

def can_participate_meeting?(current_user)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this needs to be a separate method from can_participate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because Rubocop complains...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you can add a skip rule to rubocop.yml

@ghost ghost added the status: WIP label May 4, 2018
@isaacmg410
Copy link
Copy Markdown
Contributor Author

@decidim/lot-core all checks passed :)

@mrcasals mrcasals merged commit eb75f6f into master May 9, 2018
@mrcasals mrcasals deleted the 3044_meeting_types branch May 9, 2018 07:24
isaacmg410 pushed a commit to CodiTramuntana/decidim that referenced this pull request May 25, 2018
* meeting types

* add database fields

* add fields to commands and js

* add organizer to meetings, pending frontend

* add organizer to frontend, pending specs

* improve specs, and locales

* remove comments

* fix data picker builder form

* fix locales, and form builder

* add changelog line.

* change data picker, to select picker of belongs_to

* fix codeclimate

* uncoment specs

* remove comment routes

* mettings only visibles for users registerd

* fix meeting_form, add labels, pending specs

* fix some specs

* fix rubocop offenses

* fix specs

* add space before %> on layout.

* rmeove unnecessary regexp and add spec for organizers json

* apply changes requested on review and add system spec

* fix rubocop offenses, and requested changes

* remove method on controller and use one of model

* fix methods for specs

* change booleans field names, specs, and apply requested changes

* change to private_meeting

* Change organizers action to users controller index action

* fix rubocop and when copy meeting

* group two methods into one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants