Project

General

Profile

Add activity to redmine

Added by Tingel Tangel over 11 years ago

Hi,

i want to add a new activity group to redmine, but i have the problem, that when i reload the user show page i get a sql-error because, the activity is not linkted to any project but to the specified user.

error:

SQLite3::SQLException: no such column: projects.status ... 

init.rb from the plugin:

Redmine::Activity.map do |activity|
  activity.register(:blogs,{:class_name => 'Blog'})
end

sql statment:

 
SELECT  "blogs"."id" AS t0_r0, "blogs"."summary" AS t0_r1, "blogs"."description" AS t0_r2, "blogs"."title" AS
 t0_r3, "blogs"."comments_count" AS t0_r4, "blogs"."created_on" AS t0_r5, "blogs"."project_id" AS t0_r6, "blogs"."author_id" AS t0_r7, "users"."id" AS t1_r0, "users"."login" AS t1_r1, "users"."hashed_password" AS 
t1_r2, "users"."salutation" AS t1_r3, "users"."title" AS t1_r4, "users"."firstname" AS t1_r5, "users"."lastname" AS t1_r6, "users"."department" AS t1_r7, "users"."street" AS t1_r8, "users"."city" AS t1_r9, "users"."zipcode" AS t1_r10, "users"."phone" AS t1_r11, "users"."fax" AS t1_r12, "users"."mail" AS t1_r13, "users"."admin" AS
 t1_r14, "users"."status" AS t1_r15, "users"."last_login_on" AS t1_r16, "users"."language" AS t1_r17, "users"."auth_source_id" AS t1_r18, "users"."created_on" AS t1_r19, "users"."updated_on" AS t1_r20, "users"."type" AS t1_r21, "users"."identity_url" AS t1_r22, "users"."mail_notification" AS t1_r23, "users"."salt" AS t1_r24, "users"."confirm" AS t1_r25 FROM "blogs" 
LEFT OUTER JOIN "users" ON "users"."id" = "blogs"."author_id" AND "users"."type" IN ('User', 'AnonymousUser') WHERE (blogs.author_id = 1) AND (projects.status=1) ORDER BY blogs.id DESC LIMIT 10)

model activation:

  acts_as_activity_provider :type => 'blogs',
                            :timestamp => "#{Blog.table_name}.created_on",
                            :author_key => "#{Blog.table_name}.author_id",
                            :permission => :view_blogs,
                            :find_options => {:select => "#{Blog.table_name}.*",:include => [:author]}

and the best part is, if i try to execute the sql statement to the database without the "AND (project.state = 0) it works fine

I hope i find some help ;)


Replies (1)

RE: Add activity to redmine - Added by Tingel Tangel over 11 years ago

ok, i found the solution, but i think it's not the best one

i added a :no_project symbol to the acts_as_activity_provider options and change the find_events method slightly

if provider_options.has_key?(:permission)
+  if !(provider_options.has_key?(:no_project))
   scope = scope.scoped(:conditions => Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options))
+  end

and it works

please send your opinions

    (1-1/1)