-
Notifications
You must be signed in to change notification settings - Fork 30
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
can't enable badge for one user but works when enabled for all #97
Comments
Hi, thanks for trying this plugin and reporting issue. |
Hi it is v0.1.0, latest from here |
@Henderxx Thanks for this information. I'll check it. |
Could you please tell me if you use any other plugins? Also what is the database engine you use? |
Sure, i have few other plugins and all is using Mysql database |
Sorry I could not reproduce this problem. |
there is one, it's theme changer. it adds one option in users profile, allowing them to change how redmine looks. I'll try tomorrow in new installation of redmine with only issue badge plugin enabled if error exists. If you want some logs i can give them |
Ok i did some test, i've installed redmine with bitnami on virtual windows machine, then added plugin and make bundle install and rake commands. All installed, then i tried to enable plugin for my admin account effect was the same, option checked but when i pressed save all is gone to defaults and unchecked. I tried it on firefox and then on chrome on both same results. |
same problem here. I have no user profile extension plugin installed. |
@mrniemand Thanks for additional information. It's variable for me. |
Database: Mysql 5.5 OS is Win7 32bit, redmine is installed manually. All users have been created before i installed the plugin. |
I could not reproduce in the production env with mysql and using the same plugins.... Could you tell me which browser you use? And if you checked “Enabled” on user’s preference page, the request parameter is sent like this. |
i've tried it on chrome and firefox, both had same issue. I'll try tomorrow on opera and maybe some others. Can you tell me is this plugin using some date and time format when request is send? i have seen some similiar problems on other few programs when date and time format where with different separators. my format is rrrr-MM-dd for short time format and d MMMM rrrr for long format |
i used Internet Explorer. Still after adding the line manual no change within the redmine ui is stored there. Redmine Log is correct and shows the new config: |
i also get an HTTP Result 302. |
@mrniemand @Henderxx Thanks a lot!! |
@mrniemand @Henderxx diff --git a/init.rb b/init.rb
index 2a5b4f4..c0d4212 100644
--- a/init.rb
+++ b/init.rb
@@ -51,6 +51,13 @@ Redmine::Plugin.register :redmine_issue_badge do
'activate_for_all_users' => 'false',
'enabled_polling' => false
}
+
+ Rails.configuration.to_prepare do
+ require_dependency 'my_controller'
+ unless MyController.included_modules.include?(IssueBadge::MyControllerPatch)
+ MyController.prepend IssueBadge::MyControllerPatch
+ end
+ end
rescue ::Redmine::PluginRequirementError => e
raise ::Redmine::PluginRequirementError.new(issue_badge_version_message(e.message)) # rubocop:disable Style/RaiseArgs
end
diff --git a/lib/issue_badge/my_controller_patch.rb b/lib/issue_badge/my_controller_patch.rb
index f1f2d83..7e61856 100644
--- a/lib/issue_badge/my_controller_patch.rb
+++ b/lib/issue_badge/my_controller_patch.rb
@@ -26,4 +26,3 @@ module IssueBadge
end
end
-MyController.prepend IssueBadge::MyControllerPatch ※ v0.1.x (Support Redmine3.x) was applied this workaround to prevent some conflict or unloaded issue. But I’m sorry I have not much experiences about Redmine4.x which running various environment, rails application server and so on. If above is effective, I’m going to apply soon. And here is my log when submitting account setting, Started PUT "/my/account" for ::1 at 2019-08-22 14:14:18 +0900
Processing by MyController#account as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>”xxxx", "user"=>{"firstname"=>"Redmine", "lastname"=>"Admin", "mail"=>"admin@example.net", "language"=>"en", "mail_notification"=>"all", "notified_project_ids"=>[""]}, "commit"=>"Save", "pref"=>{"no_self_notified"=>"1", "hide_mail"=>"1", "time_zone"=>"", "comments_sorting"=>"asc", "warn_on_leaving_unsaved"=>"1", "textarea_font"=>"", "recently_used_projects"=>"3", "history_default_tab"=>"notes"}, "issue_badge"=>{"enabled"=>"1", "show_assigned_to_group"=>"1", "badge_order"=>"oldest"}}
Token Update All (1.7ms) UPDATE "tokens" SET "updated_on" = '2019-08-22 14:14:18.446712' WHERE "tokens"."user_id" = ? AND "tokens"."value" = ? AND "tokens"."action" = ? [["user_id", 1], ["value", “xxxxxx"], ["action", "session"]]
(0.2ms) SELECT MAX("settings"."updated_on") FROM "settings"
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('User', 'AnonymousUser') AND "users"."status" = ? AND "users"."id" = ? LIMIT ? [["status", 1], ["id", 1], ["LIMIT", 1]]
Current user: admin (id=1)
IssueBadgeUserSetting Load (0.9ms) SELECT "issue_badge_user_settings".* FROM "issue_badge_user_settings" WHERE "issue_badge_user_settings"."user_id" = ? LIMIT ? [["user_id", 1], ["LIMIT", 1]]
{"enabled"=>"1", "show_assigned_to_group"=>"1", "badge_order"=>"oldest"}
(0.2ms) begin transaction
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('User', 'AnonymousUser') AND "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
IssueBadgeUserSetting Update (0.9ms) UPDATE "issue_badge_user_settings" SET "enabled" = ?, "updated_on" = ? WHERE "issue_badge_user_settings"."id" = ? [["enabled", 1], ["updated_on", "2019-08-22 14:14:18.459522"], ["id", 1]]
(1.3ms) commit transaction
UserPreference Load (0.2ms) SELECT "user_preferences".* FROM "user_preferences" WHERE "user_preferences"."user_id" = ? LIMIT ? [["user_id", 1], ["LIMIT", 1]]
EmailAddress Load (0.1ms) SELECT "email_addresses".* FROM "email_addresses" WHERE "email_addresses"."user_id" = ? AND "email_addresses"."is_default" = ? LIMIT ? [["user_id", 1], ["is_default", 1], ["LIMIT", 1]]
(0.1ms) begin transaction
CustomField Load (0.6ms) SELECT "custom_fields".* FROM "custom_fields" WHERE (type = 'UserCustomField') ORDER BY "custom_fields"."position" ASC
CustomValue Load (0.2ms) SELECT "custom_values".* FROM "custom_values" WHERE "custom_values"."customized_id" = ? AND "custom_values"."customized_type" = ? [["customized_id", 1], ["customized_type", "Principal"]]
Member Update All (0.3ms) UPDATE "members" SET "mail_notification" = 0 WHERE "members"."user_id" = ? [["user_id", 1]]
(0.1ms) commit transaction
(0.1ms) begin transaction
(0.1ms) commit transaction
Redirected to http://localhost:3000/my/account
Completed 302 Found in 45ms (ActiveRecord: 7.5ms)
|
Don't test this patch on production installation! ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "issue_badge_user_settings" does not exist |
The error above was related the plugin folder. I removed the plugin's folder after uninstall, then "Internal Error" gone. |
Hi, @tanertas
Are you also remove the plugin folder from REDMINE_ROOT/plugins?
Yes, to uninstall, you have to run migration VERSION=0 task, remove plugin’s folder and restart Redmine. |
Hi, @tanertas @mrniemand @Henderxx Following this code, updating IssueBadgeUserSetting is done when request method is “PUT”.
The log I provided, controller is received as ‘PUT’ method.
If your requests always sent via “POST” method, I think this workaround is effective. Change from
To
|
Hi, @akiko-pusu i'm back from short offline. I'll do test in this week with patch. But for quick test i did change in
And this one did the trick for me
|
@Henderxx Thanks for your cooperation. If you could, please try this patch. --- a/lib/issue_badge/my_controller_patch.rb
+++ b/lib/issue_badge/my_controller_patch.rb
@@ -6,8 +6,12 @@ module IssueBadge
def account
user = User.current
+
+ logger.info "[info] IssueBadge::MyControllerPatch is applied: #{request.method} / request.put? : #{request.put?}}"
+
@issue_badge = IssueBadgeUserSetting.find_or_create_by_user_id(user)
- if request.put?
+
+ if request.put? || request.post?
begin
logger.info(badge_params)
logger.warn "Can't save IssueBadge." unless @issue_badge.update(badge_params)
@@ -26,4 +30,3 @@ module IssueBadge
end
end
When get my account:
When update my account:
|
This also worked for me. Thanks. |
I got some troubles with applying this changes as patch for plugin. it was my first one :) and hey everyday we learn something new. First i got some problem with searching file But i managed to do it. I deleted two "end's" from last two lines and then was something like success and file was changed Then i restarted redmine and i think it works
|
@tanertas Thanks for your trying and telling your situation! @Henderxx It seems you use BitNami Redmine and Apache as web server. This is also an important information for me :) |
@akiko-pusu |
Accept POST method with _method param. (#97)
Workaround is merged into master on commit: 59bd9f3. |
I tested with latest master( 60ddcd4) but i didn't work for me. |
Hello i've just installed aand i got little error, i've tried to enable plugin for some users but the checkbox will drop selection as i save settings and still be unchecked. But when i enabled plugin in plugin settings for all users it just works with standard options therefore i cannot change any setting again in my profile page
I'm using
Redmine version 4.0.1.stable
Ruby version 2.4.5-p335 (2018-10-18) [i386-mingw32]
Rails version 5.2.2
all installed with bitnami on windows machine
The text was updated successfully, but these errors were encountered: