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

Threads to be sent to municipality #741

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

PetrDlouhy
Copy link
Contributor

@PetrDlouhy PetrDlouhy commented Dec 3, 2017

This is unfinished functionality prototype meant to be discussed and finished before pulling.

This PR adds new button "Send to the municipality" which adds new message thread with parameter that it should be send to the municipality. We are working in cooperation with Prague city council on this function which will send automatically Issue data to the official portal http://zmente.to.
The new thread form is prefilled with the issue title and description, the user can modify this or leave it.
This function is available only for members of the groups to prevent inexperienced users from sending low quality issues.

There some things, that has to be solved before pulling:

  • The administrator should be able to add new external services user can choose from.
  • If there is no such service, user should not see the button.

Please comment, what do you think about this function.

@nikolai-b
Copy link
Contributor

Wow, that is an exciting possibility. I think it is really for @mvl22 to deal with as this is not a coding issue so I can't comment.

@mvl22
Copy link
Member

mvl22 commented Dec 3, 2017

Thanks for this, Petr!

There seem to be hard-coded references to the specific service (zmente.to) in the code - I think this stuff should be generalised, perhaps in the form of a driver file which implements particular services and then the settings contain a drop down of the available drivers (albeit only one at present).

On a policy question, if any member can submit an issue externally, what is required to ensure that the submission represents the considered view of the members of the discussion thread as a whole? For instance, couldn't a new user come along, and submit something wildly different to the consensus view?

@PetrDlouhy
Copy link
Contributor Author

@mvl22 For now, this only sets submit_external parameter of message thread to the service identifier value (zmenteto). Then the marked threads can be filtered in the API. I solved the sending from Cyclescape API to Změňte.to API by external script. Although it might be desired to include external service senders to the code in the future, I went the simplest way for me now.

I would like to add a possibility to configure possible services in the site config. My idea is, that user only fills service name and service identifier (and maybe other identifiers in the future) to the table. If the table is empty, no Send to municipality button is shown.
But I am not quite sure how to do this. The only way I can imagine is changing the submit_external parameter to foreign key to the service table.

Změňte.to is a service opened to the wide public, so opening this possibility to the group member is more restrictive than the original service. So for my use-case, this is OK and I would like to keep this simple. If anyone wants to add some service that requires more restrictive approach, he can add it by some settings of the services.

@PetrDlouhy PetrDlouhy force-pushed the feature/municipality-threads branch 4 times, most recently from 9f6d9b0 to 63af588 Compare December 14, 2017 16:29
@PetrDlouhy PetrDlouhy changed the title (WIP) Threads to be sent to municipality Threads to be sent to municipality Dec 14, 2017
@PetrDlouhy
Copy link
Contributor Author

I updated this PR and I consider it to be feature complete now. I changed the thread parameter to external_service foreign key and added external services configuration to admin.

So now there is no reference to any particular service and everything is done by configuration in admin. If no service is added in admin, no "Send to municipality" button is displayed, so nothing changes.

Please review.

@PetrDlouhy PetrDlouhy force-pushed the feature/municipality-threads branch 2 times, most recently from 5d6e8ed to 2b1891d Compare December 19, 2017 11:32
@PetrDlouhy
Copy link
Contributor Author

I rebased this to cs/staging

@nikolai-b
Copy link
Contributor

Thanks @PetrDlouhy I don't have time to review this one properly yet and I'd like to do it after the next release, do you mind it waiting here for a bit?

Thanks

@PetrDlouhy
Copy link
Contributor Author

I would like, if it got there, but I cannot force you :-)

@PetrDlouhy
Copy link
Contributor Author

@nikolai-b When will you have time to review this? If you write me in advance, I could rebase this before your review.

@mvl22
Copy link
Member

mvl22 commented Aug 1, 2018

I could rebase this before your review.

Yes, if you could update to the latest code, that will speed up review - I see there is a conflict noted for instance.

@PetrDlouhy
Copy link
Contributor Author

@mvl22 OK, rebased.

Copy link
Contributor

@nikolai-b nikolai-b 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 unsure about the UI change.

screenshot from 2018-09-17 19-21-16

Which creates a normal new thread and marks it as external which presumably your script then is able to pull in from the API. Why not just add it as a drop down (but allow it to be blank) whenever a new thread is created?

Other than that the code is fine, I've made a few minor comments. Thank you @PetrDlouhy !


def create
@external_service = ExternalService.new(permitted_params)
puts @external_service
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll remove this after merging.

<div class="permissions">shared</div>
<div class="thread-parameters">
<div class="permissions">shared</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this whole code is left over from the initial design (i.e. it isn't used live). @mvl22 was there a reason the original designs were kept as part of this repository? Can we delete it? They will exists in git if we do ever need to refer to them.

Copy link
Member

Choose a reason for hiding this comment

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

was there a reason the original designs were kept as part of this repository

Because the design has never actually been fully implemented yet! That said, I am trying to get round to commissioning a fresh new design that mops up piles of usability issues.

@@ -49,6 +49,10 @@
%aside#sidebar.wide
- if permitted_to? :create, :issue_message_threads
= link_to t(".new_thread", count: @issue.threads.count), new_issue_thread_path(@issue), class: "btn-green", rel: "#overlay"
- if current_user and current_user.groups.present?
Copy link
Contributor

Choose a reason for hiding this comment

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

and is a trick in ruby and doesn't do things sensibly, I'll change to && when I merge

"#{id}-#{short_name}"
end

protected
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this is here?

@@ -0,0 +1,9 @@
class AddSubmitExternalToMessageThread < ActiveRecord::Migration
def change
add_column :message_threads, :external_service_id, :integer
Copy link
Contributor

Choose a reason for hiding this comment

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

If we use
add_reference :message_threads, :external_service, foreign_key: true
it adds and index and preserves referential integrity (i.e. we can't have a thread referencing a non-existent external service.

create_table :external_services do |t|
t.string :name, null: false
t.string :short_name, null: false
end
Copy link
Contributor

Choose a reason for hiding this comment

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

We want a uniqueness constraint on :short_name
add_index :external_services, :short_name, unique: true

t.string :short_name, null: false
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

In pulls it helps if you also run rake db:migrate and commit the schema changes.

has_many :threads, class_name: 'MessageThread', inverse_of: :external_service

validates :name, presence: true, uniqueness: true
validates :short_name, presence: true, uniqueness: true, subdomain: true
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? As in what is the difference between the name and short name? Why not just use the name?

end
@message = @thread.messages.build
@message.body = issue.description
@thread.title = issue.title
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about setting the thread title equal to the issue title.
I think it should be:
Issue: New housing will be built
Thread: Increased congestion on the road
Thread: Cycle Parking on the New housing application is poor

etc.

See #43 for context.

@mvl22
Copy link
Member

mvl22 commented Sep 17, 2018

which adds new message thread with parameter that it should be send to the municipality. We are working in cooperation with Prague city council on this function which will send automatically Issue data to the official portal http://zmente.to.

To be clear - is this purely copying the initial problem report to the municipality?

@nikolai-b
Copy link
Contributor

@mvl22 is #741 (comment) addressed to me or @PetrDlouhy ? I think the Send To Municipality button will make a new thread and mark it as such so the thread is sent to the external service.

@mvl22
Copy link
Member

mvl22 commented Sep 17, 2018

@mvl22 is #741 (comment) addressed to me or @PetrDlouhy?

To Petr.

I think the Send To Municipality button will make a new thread and mark it as such so the thread is sent to the external service.

Ah, this is not what I was expecting. Peter - why does a report also create a new thread? Can these not be separated into "Create a new thread" (which already exists) and "Send to municipality" (as to be added)? I think it would be clearest to keep these two things completely separate.

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.

None yet

3 participants