-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartist_view_wdg.py_prep_Python
More file actions
176 lines (112 loc) · 4.95 KB
/
artist_view_wdg.py_prep_Python
File metadata and controls
176 lines (112 loc) · 4.95 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
###########################################################
#
# Copyright (c) 2005, Southpaw Technology
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
#
__all__=['ArtistViewWdg']
from pyasm.common import Environment
from pyasm.search import Search
from pyasm.biz import StatusEnum, Pipeline, Project
from pyasm.web import Widget, WebContainer, SpanWdg
from pyasm.widget import CheckboxWdg
class ArtistViewWdg(SpanWdg):
def init(my):
my.add("Show assigned only: ")
my.checkbox = CheckboxWdg("show_assigned_only")
my.checkbox.set_option("value", "on")
my.checkbox.set_persistence()
my.checkbox.add_event("onclick", "document.form.submit()")
my.add(my.checkbox)
my.add_class("med")
def is_supervisor(my):
# if the user is a supervisor, look at all of the assets
project = Project.get_project_name()
security = Environment.get_security()
return security.check_access("prod/%s" % project, "model/supervisor", "true")
def is_artist(my):
# if the user is a artist, look at all of the assets
project = Project.get_project_name()
security = Environment.get_security()
return security.check_access("prod/%s" % project, "model/artist", "true")
def alter_search(my, search):
# get all of the relevant tasks to the user
task_search = Search("sthpw/task")
task_search.add_column("search_id")
# only look at this project
project = Project.get_project_name()
task_search.add_filter("search_type", search.get_search_type())
# figure out who the user is
security = Environment.get_security()
login = security.get_login()
user = login.get_value("login")
print "is_artist: ", my.is_artist()
print "is_supervisor: ", my.is_supervisor()
# do some filtering
web = WebContainer.get_web()
show_assigned_only = my.checkbox.get_value()
show_process = web.get_form_values("process")
if not show_process or show_process[0] == '':
show_process = []
show_task_status = web.get_form_values("task_status")
if not show_task_status or show_task_status[0] == '':
show_task_status = []
if show_assigned_only == "on":
task_search.add_filter("assigned", user)
if show_process:
where = "process in (%s)" % ", ".join( ["'%s'" % x for x in show_process] )
task_search.add_where(where)
if show_task_status:
where = "status in (%s)" % ", ".join( ["'%s'" % x for x in show_task_status] )
task_search.add_where(where)
else:
task_search.add_where("NULL")
# record the tasks
my.tasks = task_search.get_sobjects()
# get all of the sobject ids
sobject_ids = ["'%s'" % x.get_value("search_id") for x in my.tasks]
# get all of the sobjects related to this task
if sobject_ids:
search.add_where( "id in (%s)" % ", ".join(sobject_ids) )
class SupervisorViewWdg(Widget):
def init(my):
my.add("Process: ")
checkbox = CheckboxWdg("process")
checkbox.set_option("value", "on")
checkbox.set_persistence()
checkbox.add_event("onclick", "document.form.submit()")
my.add(checkbox)
def filter_sobjects(my, orig_sobjects):
# look for groups that are relevant
groups = Environment.get_security().get_groups()
login = Environment.get_security().get_login()
# either we are user centric or process centric
user = login.get_value("login")
sobjects = []
# filter out sobjects that do not have appropriate tasks
if orig_sobjects:
search_type = orig_sobjects[0].get_search_type()
ids = [str(x.get_id()) for x in orig_sobjects]
search = Search("sthpw/task")
search.add_filter("search_type", search_type)
search.add_where("search_id in (%s)" % ",".join(ids) )
# get only tasks assigned to a user
show_assigned_only = True
if show_assigned_only:
search.add_filter("assigned", user)
search.add_where("status in ('Pending','In Progress')")
search.add_where("status is NULL")
tasks = search.get_sobjects()
task_search_ids = [int(x.get_value("search_id")) for x in tasks]
# once we have all of the tasks for this episode, we filter
# out any assets that don't have these tasks
for orig_sobject in orig_sobjects:
search_id = orig_sobject.get_id()
if search_id in task_search_ids:
sobjects.append(orig_sobject)
return sobjects