/
user.py
84 lines (67 loc) · 2.36 KB
/
user.py
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
#!/usr/bin/env python
import settings
import header
import footer
import ticketsModule
from twisted.web.resource import Resource
# Ask to login or rate annonymously
# Title
# Go to main site
# Show ticket's author badge
# Show advertisement
class Main(Resource):
def __init__(self):
Resource.__init__(self)
def render(self, request):
html = ''
html += '<html>'
html += '<body>'
html += '<center>'
html += header.Main(request)
try:
userId = request.args.get('id')
userId = userId[0]
except:
userId = 0
if userId == 0:
html += '<table>'
html += '<tr bgcolor = "#FF0000">'
html += '<td align = "center">No user id specified</td>'
html += '</tr>'
html += '</table>'
else:
tickets = ticketsModule.getByAuthor(userId)
if tickets:
html += '<table>'
html += '<tr bgcolor = "#00FF00">'
html += '<td align = "center">id</td>'
html += '<td align = "center">status</td>'
html += '<td align = "center">timestamp</td>'
html += '</tr>'
count = 0
for ticket in tickets:
ticketTimestamp = float(ticket[0])
ticketId = str(ticket[1])
ticketStatus = ticket[3]
ticketTimestamp = settings.convertTimestamp(ticketTimestamp)
count += 1
if count % 2 == 0:
bgcolor = '#E0E0E0'
else:
bgcolor = '#FFFFFF'
html += '<tr bgcolor = "%s">' % bgcolor
html += '<td align = "center">%s</td>' % ticketId
html += '<td align = "center">%s</td>' % ticketStatus
html += '<td align = "center">%s</td>' % ticketTimestamp
html += '</tr>'
html += '</table>'
else:
html += '<table>'
html += '<tr bgcolor = "#FF0000">'
html += '<td align = "center">User has no transactions recorded</td>'
html += '</tr>'
html += footer.Main()
html += '</center>'
html += '</body>'
html += '</html>'
return html