[062892]: / ForgeTracker / forgetracker / tasks.py  Maximize  Restore  History

Download this file

56 lines (45 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import logging
from datetime import datetime
from tg import tmpl_context as c
from allura.lib.decorators import task
from allura.lib import helpers as h
from allura import model as M
log = logging.getLogger(__name__)
@task
def update_bin_counts(app_config_id):
app_config = M.AppConfig.query.get(_id=app_config_id)
app = app_config.project.app_instance(app_config)
with h.push_config(c, app=app):
app.globals.update_bin_counts()
@task
def move_tickets(ticket_ids, destination_tracker_id):
c.app.globals.move_tickets(ticket_ids, destination_tracker_id)
@task
def bulk_edit(**post_data):
try:
M.artifact_orm_session._get().skip_last_updated = True
c.app.globals.update_tickets(**post_data)
# manually update project's last_updated field at the end of the
# import instead of it being updated automatically by each artifact
# since long-running task can cause stale project data to be saved
M.Project.query.update(
{'_id': c.project._id},
{'$set': {'last_updated': datetime.utcnow()}})
finally:
M.artifact_orm_session._get().skip_last_updated = False