Eptikar-IT-Solutions / openngo

OpenNGO is a platform to help NGOs better help the world!
Apache License 2.0
8 stars 2 forks source link

Activity trello integration #1

Open 0mongoose opened 8 years ago

0mongoose commented 8 years ago

We've already added trello integration for projects, by making each project create a board, and a webhook to change the project based on changes to the board. We'd like each activity to create a card and checklist, and keep references to them, as well as creating a webhook to change the status of the card based on the list it is in. The breakdown is:

  1. Generate migrations to add card and checklist to the Activity model. These will be strings used to save the Trello ids of the corresponding checklist
  2. Generate a migration to add status to the Activity model. Where statuses are the same as the list names at Trello [To Do, Doing, Done], Or any customized lists set at Trello Board.

To learn more about migration check the railsdocs link: http://edgeguides.rubyonrails.org/active_record_migrations.html

  1. Add a function to the the Activity model to create a card (named like the activity) and a checklist (called to do, for example) with every new instance of Activity, and save their ids in the card and board attributes of Activity model.

hint: use anafter_create callback

  1. Add a Trello Webhook to update an activity status every time a card moved from list to the other.

We've already created a branch called trello_integration which includes tests to help guide the process and ensure that the results are as expected. To run them, run rspec spec/models/activity_spec.rb. Make sure all your work is done in this branch.

P.S: The trello member token and trello developer key are saved as environment variables in a file in the /config/initializers/app_env_vars.rb . There's is an example one in /config/initializers/app_env_vars_example.rb , which you should rename and add your own keys to. Note that is part of the .gitignore file for security reasons. You will also need to change the /config/initializers/setup_mailer.rb file if you want to use mail functionality.

mohamedabbasos commented 8 years ago

@0mongoose , I can't find the trello config file in this path /config/initializers/app_env_vars.rb , also in this path /config/initializers/app_env_vars_example.rb

arwaahmed commented 8 years ago

@mohamedabbasos you need first to checkout to trello_integration branch instead of working on master and in this branch you will find the file.

mohamedabbasos commented 8 years ago

@arwaahmed thanks.

arwaahmed commented 8 years ago

app_env_vars.rb should be created by you with app_env_vars_example.rb as a reference. It won't be pushed to the repo, since it is include in the .gitignore file.

mohamedabbasos commented 8 years ago

@arwaahmed i got it , thanks

i pull the branch and create the file app_env_vars.rb update it with

The app opened successfully in the browser , i logged in with the demo data but when i trying to add a new project in the pathprojects/new i get that error

CanCan::AccessDenied in ActivitiesController#new You are not authorized to access this page.

the same error appears when i try to add new activity or list members or donors .. etc

i know that my questions are about configurations not a bout this issue , but i don't know where to put them

arwaahmed commented 8 years ago

@mohamedabbasos The cause of the error is that the current user is assigned to the role Guest which has limited access. First you need to pull the latest changes (changes related to seed.rb). Then go ahead and seed the database (It is better if you reset db first). A user with an role of an admin would be created and with it you can access everything.

As for configuration (though not related to the error you mentioned) it seems where you put them is fine as long as you used a valid email credentials in the /config/initializers/app_env_vars.rb and changed the /config/initializers/setup_mailer.rb accordingly

mohamedabbasos commented 8 years ago

@arwaahmed

First you need to pull the latest changes

I was cloned a few days ago (about two days), and the last commit to the project before that also i check the db/seeds.rb and i found this line User.create(name: 'admin', full_name: 'Administrator', email: 'alias@example.com', password: '12345678', password_confirmation: '12345678', active: true, confirmed_at: Time.now, role_id: role2.id) i think that is mean the user with the email : 'alias@example.com have an admin permissions check this https://github.com/Eptikar-IT-Solutions/openngo/blob/master/db/seeds.rb#L13

and for this /config/initializers/setup_mailer.rb Can i use Eptikar mail account ? as demo or I should use my private email

arwaahmed commented 8 years ago

@mohamedabbasos There were some more recent changes was pushed to solve a bug on the seed. You should pull and then clear the database preferably and then reseed the database.

Or as an alternative you can make sure that the role admin has permissions {all: true} and then set role_id for your user to the id of that role.

As for smtp settings you need to use your own private account.

mohamedabbasos commented 8 years ago

@arwaahmed This code form my local files: role2 = Role.create(name: 'Admin', permissions:{all: true}) User.create(name: 'admin', full_name: 'Administrator', email: 'alias@example.com', password: '12345678', password_confirmation: '12345678', active: true, confirmed_at: Time.now, role_id: role2.id)

And this mean its updated :/

Because its congruous with your words and with the code here: https://github.com/Eptikar-IT-Solutions/openngo/blob/master/db/seeds.rb#L11

As for smtp settings you need to use your own private account.

OK , But i don't know tell now whats the importance of this part ? and is it related to the issue ? can i escape it ?

arwaahmed commented 8 years ago

@mohamedabbasos As for SMTP settings, it is not really related to the issue . It is needed when creating a new user. To escape it set confirmed_at to Time.now(for instance), and no confirmation email would be sent. This is as the creation of user in seed file: User.create(name: 'admin', full_name: 'Administrator', email: 'alias@example.com', password: '12345678', password_confirmation: '12345678', active: true, confirmed_at: Time.now , role_id: role2.id)

As for the role issue the lines of code you mentioned earlier is not up to date. Please pull first. You can either reseed database after clearing users and roles tables and it will work fine.

Or you can copy the the lines of code in seed to the rails console, whatever work for you that will achieve the result of a user has the role with permissions: {all: true}.