Project

General

Profile

Actions

Patch #32196

closed

Allow import time entries for other users

Added by Marius BĂLTEANU over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Category:
Time tracking
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

#28234 allows importing time entries only for the current user. I think we should support importing for other users as well and I see two options:

1. We allow based on the new permission "Log spent time for other users" added in #3848.
2. We add a new permission "Import time entries" as we already have for issues.

On the long term, I think option 2 it's better because:
- it's consistent with the behaviour from issues
- we can allow importing time entries on multiple projects once.

Any feedback is welcome.


Files


Related issues

Related to Redmine - Feature #28234: Add CSV Import for Time EntriesClosedGo MAEDA

Actions
Related to Redmine - Feature #3848: Permission to log time for another userClosedJean-Philippe Lang2009-09-11

Actions
Actions #1

Updated by Marius BĂLTEANU over 4 years ago

Actions #2

Updated by Kevin Fischer over 4 years ago

+1
Sounds good.

I also agree that option 2 would be better.

Actions #3

Updated by Marius BĂLTEANU over 4 years ago

  • Assignee set to Marius BĂLTEANU
  • Target version set to Candidate for next major release
Actions #4

Updated by Bernhard Rohloff over 4 years ago

  • Category set to Time tracking

+1
I think option 2 is the better one, too.

Actions #5

Updated by Marius BĂLTEANU over 4 years ago

  • Assignee deleted (Marius BĂLTEANU)
  • Target version changed from Candidate for next major release to 4.1.0
Actions #6

Updated by Marius BĂLTEANU over 4 years ago

  • File 0002-Allow-import-time-entries-for-other-users-if-current.patch added
  • File 0001-Add-permission-to-import-time-entries.patch added

I'm attaching two patches:

1. 0001-Add-permission-to-import-time-entries.patch which adds the missing "Import time entries" permission. I think it is better to have this permission in order to be consistent with import issues from CSV. Also, some Redmine administrators don't want to allow importing time entries from CSV at all.
2. 0002-Allow-import-time-entries-for-other-users-if-current.patch which allows users with "log_time_for_other_users" permission to import time entries for other users as well.

Actions #7

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0002-Allow-import-time-entries-for-other-users-if-current.patch)
Actions #8

Updated by Marius BĂLTEANU over 4 years ago

  • File 0002-Allow-import-time-entries-for-other-users-if-current.patch added
Actions #9

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0002-Allow-import-time-entries-for-other-users-if-current.patch)
Actions #10

Updated by Marius BĂLTEANU over 4 years ago

  • File 0002-Allow-import-time-entries-for-other-users-if-current.patch added
Actions #11

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0001-Add-permission-to-import-time-entries.patch)
Actions #12

Updated by Marius BĂLTEANU over 4 years ago

  • File 0001-Add-permission-to-import-time-entries.patch added
Actions #13

Updated by Marius BĂLTEANU over 4 years ago

Made some minor changes to attachment:0002-Allow-import-time-entries-for-other-users-if-current.patch in order to allow selecting the user from column mapping and not only from CSV.

Actions #14

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0002-Allow-import-time-entries-for-other-users-if-current.patch)
Actions #15

Updated by Go MAEDA over 4 years ago

Marius BALTEANU wrote:

1. 0001-Add-permission-to-import-time-entries.patch which adds the missing "Import time entries" permission. I think it is better to have this permission in order to be consistent with import issues from CSV. Also, some Redmine administrators don't want to allow importing time entries from CSV at all.

I agree. CSV import feature is a dangerous feature. A malicious or ignorant user can easily ruin the spent time page by bulk-importing junk data. so, the permission is useful to prevent such incidents.

Actions #16

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0001-Add-permission-to-import-time-entries.patch)
Actions #17

Updated by Marius BĂLTEANU over 4 years ago

Go MAEDA wrote:

Marius BALTEANU wrote:

1. 0001-Add-permission-to-import-time-entries.patch which adds the missing "Import time entries" permission. I think it is better to have this permission in order to be consistent with import issues from CSV. Also, some Redmine administrators don't want to allow importing time entries from CSV at all.

I agree. CSV import feature is a dangerous feature. A malicious or ignorant user can easily ruin the spent time page by bulk-importing junk data. so, the permission is useful to prevent such incidents.

Great, thanks. I'm attaching a new version of the patch which checks for the proper permission in /app/views/timelog/index.html.erb.

I think now both patches are ready for commit as part of #28234.

Actions #18

Updated by Go MAEDA over 4 years ago

  • Related to Feature #3848: Permission to log time for another user added
Actions #19

Updated by Go MAEDA over 4 years ago

Regarding the patch 0002-Allow-import-time-entries-for-other-users-if-current.patch, I think the field mapping for the User field should default to the current user for the consistency with the behavior when the current user does not have "Import time entries" permission.

When a user does not have "Import time entries" permission, the user cannot (and does not necessary to) to set field mapping for the User field and data are always imported as their own time entries.

But when a user has the permission, the same operation results in an error saying that "User cannot be blank. User is invalid".

This can be resolved if the User field defaults to the current user.

Actions #20

Updated by Marius BĂLTEANU over 4 years ago

Go MAEDA wrote:

Regarding the patch 0002-Allow-import-time-entries-for-other-users-if-current.patch, I think the field mapping for the User field should default to the current user for the consistency with the behavior when the current user does not have "Import time entries" permission.

When a user does not have "Import time entries" permission, the user cannot (and does not necessary to) to set field mapping for the User field and data are always imported as their own time entries.

But when a user has the permission, the same operation results in an error saying that "User cannot be blank. User is invalid".

This can be resolved if the User field defaults to the current user.

Agree with you, I'll post the updated patch these days.

Actions #21

Updated by Dominik Ras over 4 years ago

+1 for option 2

+100 for the whole concept of adding time for other users (with sufficient permissions!!). That will save several man-days a month. You guys ROCK !!

Actions #22

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0002-Allow-import-time-entries-for-other-users-if-current.patch)
Actions #24

Updated by Jean-Philippe Lang over 4 years ago

Marius BALTEANU wrote:

Updated the second patch.

Thanks Marius. With this implementation, we can reference users with their numeric ids only. That can be a pain to fill/review in the CSV file. Is it OK or should we allow to use usernames or emails?

Actions #25

Updated by Marius BĂLTEANU over 4 years ago

Jean-Philippe Lang wrote:

Thanks Marius. With this implementation, we can reference users with their numeric ids only. That can be a pain to fill/review in the CSV file. Is it OK or should we allow to use usernames or emails?

I think it's good enough to allow user ids in a first phase and then add support for usernames or emails in 4.1.1.

Actions #26

Updated by Marius BĂLTEANU over 4 years ago

Anyway, I'll try to update my patch in the following 2 or 3 hours.

Actions #27

Updated by Jean-Philippe Lang over 4 years ago

Marius BALTEANU wrote:

Anyway, I'll try to update my patch in the following 2 or 3 hours.

No I think it's OK for now.

Actions #28

Updated by Marius BĂLTEANU over 4 years ago

Jean-Philippe Lang wrote:

Marius BALTEANU wrote:

Anyway, I'll try to update my patch in the following 2 or 3 hours.

No I think it's OK for now.

Ok, thanks for you quick response.

Actions #29

Updated by Jean-Philippe Lang over 4 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Committed, thanks.

Actions #30

Updated by Jean-Philippe Lang over 4 years ago

Marius BALTEANU wrote:

I think it's good enough to allow user ids in a first phase and then add support for usernames or emails in 4.1.1.

I made the change in order to reference users just like we reference assignees when importing issues.

Actions #31

Updated by Marius BĂLTEANU over 4 years ago

r18893 broke the translation in time_entries/imports/new:

I think we need to add both keys in the locales (as we have for issues). Sorry for not catching this.

Actions #32

Updated by Marius BĂLTEANU over 4 years ago

Also, I propose to remove this ticket from 4.1.0 because it will appear in the changelog as part of #3848 and #28234.

Actions #33

Updated by Jean-Philippe Lang over 4 years ago

  • Status changed from Reopened to Closed
  • Target version deleted (4.1.0)

Marius BALTEANU wrote:

I think we need to add both keys in the locales (as we have for issues). Sorry for not catching this.

Fixed, thanks for pointing this out.

Actions

Also available in: Atom PDF