Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to forbid changes in worklog after some period?

Alexander Yu August 27, 2015

Editing worklog shold be abale only for defenite period. For example one or two days. For this time period jira-users can change worklog. When this period of time has pass any changes not allowed.

How we can rule this question?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Alexander Yu September 27, 2015

By the way, it was very easy. Was created plPython trigger like this:

CREATE OR REPLACE FUNCTION update_trigger() RETURNS trigger AS $$
    from datetime import datetime, timedelta

    def check_rights(created, updated, startdate, updateauthor):
        now_date = datetime.now()

        a = updated.index(":")+6
        updatedStr = updated[:a]
        updated1 = datetime.strptime(updatedStr, '%Y-%m-%d %H:%M:%S')
        a = startdate.index(":")+6
        startdateStr = startdate[:a]
        startdate1 = datetime.strptime(startdateStr, '%Y-%m-%d %H:%M:%S')

        for row in plpy.execute("""SELECT parent_name FROM cwd_membership WHERE lower_child_name = '%s';""" % (updateauthor)):
        f row['parent_name'] == "something" or row['parent_name'] == "something other":        
		# Some conditions
    reportHour = 23
                    break
                else:
                    reportHour = 11

        if now_date.isoweekday() == 1:
            #This is conditions for monday
			canLog = timedelta(days = 3)
        else:
            canLog = timedelta(days = 1)
        canLogZero = timedelta(days = 0) # For conditions to not allow logi for future
        if updated1.date() == startdate1.date():
            return True
        if (updated1.date() - startdate1.date()) < canLogZero:
            return False # This is conditions for future
        elif updated1.date() - startdate1.date() <= canLog and updated1.time().hour <= reportHour:
            return True
        else:
            return False

    created = TD['new']['created']
    updated = TD['new']['updated']
    startdate = TD['new']['startdate']
    updateauthor = TD['new']['updateauthor']

    if check_rights(created, updated, startdate, updateauthor) == False:
        res = plpy.execute("   STOP SQL QUERY     ") # if conditions not allow to chenge worklog, we create not walid SQL-query

$$ LANGUAGE plpythonu;

CREATE TRIGGER UpdateWorklogTrigger
    BEFORE INSERT OR UPDATE 
    ON worklog
    FOR EACH ROW
    EXECUTE PROCEDURE update_trigger();

 

 

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2015

You can't do this in plain JIRA - the closest you can get is to block worklogs once an issue enters a certain status, but the Tempo addon does allow you to block worklogs based on the age of an issue.

Alexander Yu August 28, 2015

It is sad. What are the other variants? For example, can we create some postgresql trigger to Intercept event entering to database. In this event we will launch java-listener class to check user's group (user's right) and after it or accept chenges in database or reject, depends of user's rights. Is it possable?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2015

NO! Never do anything in a JIRA database, it will break it. Do it in JIRA - find/write an addon that can block it like Tempo does, or move the issues into a can't-log-time status after a certain time.

Alexander Yu August 28, 2015

Firstly, Tempo addon does allow us to block worklogs based on the age of an issue, but we need to block worklog based on the period. Second, Tempo has a lot of function that we do not needed. We need more exectly solution. May be possable some other plugins? Not so expensive and not so functionality. We just wont block to make chenges in worklog after some period. I think it's elementary task and pay 500$ per month for this very prodigally.

TAGS
AUG Leaders

Atlassian Community Events