Reverting Auto-Task¶
Reverting Auto-Task¶
1# Project Revert Auto-task example
2# This script should be assigned to either the "Revert (After)" or "Revert (Before)" auto-tasks.
3# It will not work in the Script Toolbox as the impact.gui.active_database_revert property is only valid
4# during a database revert operation.
5
6
7# For the "Revert (Before)" auto-task the IRevertAction object will only have Project,
8# User and OldRevision properties. The OldRevision is the revision being Reverted To or
9# being Made Current.
10
11# The "Revert (Before)" may be cancelled by setting IDatabase.accept_auto_task = False
12
13# For the "Revert (After)" auto-task the IRevertAction object will also have
14# a NewRevision property to the IDatabaseRevision of the new revision.
15# For a Revert To the OldRevision and NewRevision will be the same revision.
16# If the customer was changed as part of the revert then the OldCustomer
17# and NewCustomer properties will also be set.
18
19# All properties are read-only and cannot be modified.
20
21db = impact.active_database
22
23 # When assigned to "Revert (Before)" - revert may be cancelled using AcceptAutoTask
24 # Make sure you inform the user why they cannot revert
25 # MsgBox "You cannot revert this revision"
26 # db.accept_auto_task = False
27
28ra = impact.gui.active_database_revert
29
30
31def describe_revert_action(ra):
32 impact.gui.output_toolbox.add("Project: " + str(ra.project.reference))
33 impact.gui.output_toolbox.add("User: " + str(ra.user.login_id))
34
35 if ra.action == ipRevertAction.raRevert:
36 impact.gui.output_toolbox.add("Action: Reverting")
37 else:
38 impact.gui.output_toolbox.add("Action: Making Current")
39
40 impact.gui.output_toolbox.add("OldRevision: " + str(ra.old_revision.number))
41
42 if not ra.new_revision.isNone():
43 impact.gui.output_toolbox.add("NewRevision: " + str(ra.new_revision.number))
44 impact.gui.output_toolbox.add(" Comments: " + str(ra.new_revision.comments))
45
46 if (not ra.old_customer is None) and (not ra.new_customer is None):
47 impact.gui.output_toolbox.add("OldCustomer: " + str(ra.old_customer.full_name))
48 impact.gui.output_toolbox.add("NewCustomer: " + str(ra.new_customer.full_name))
49
50
51if not ra.isNone():
52 describe_revert_action(ra)
53
54else:
55 impact.gui.output_toolbox.add("Error: ActiveDatabaseRevert is not valid")