~bnrubin/bantrackertwo/devel

« back to all changes in this revision

Viewing changes to import.py

  • Committer: Benjamin Rubin
  • Date: 2009-08-10 16:53:45 UTC
  • Revision ID: bnrubin@romulus-20090810165345-c6en6tdw7k6rydfh
- Comments now are part of the parent Event to make templating easier
- Began some basic template work

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
    def __init__(self,id,operator,text,time):
15
15
        self.id = id
16
16
        self.operator = operator
17
 
        self.time = pickle.loads(time)
 
17
        self.time = time
18
18
        self.text = text
19
19
        self.enabled = True
20
20
        
74
74
        print 'Comments:'
75
75
        for c in self.comments:
76
76
            if c.enabled:
77
 
                print c.text
 
77
                print '%s: %s' % (c.time,c.text)
78
78
                print '-------'            
79
79
        print '-----------------------------------------------------'
80
80
    def add(self):
106
106
            if comment.enabled:
107
107
                op,status = Operator.objects.get_or_create(host=comment.operator)
108
108
                op.save()
109
 
                c = Comment(content_object=event,text=comment.text,author=op)
 
109
                c = Comment(content_object=event,text=comment.text,author=op,create_date=comment.time)
110
110
                c.save()
111
111
 
112
112
    def getComments(self,ban_id):
115
115
        comments = cursor.fetchall()
116
116
        c = []
117
117
        for comment in comments:
118
 
            c.append(LegacyComment(comment[0],comment[1],comment[2],comment[3]))
 
118
            id = comment[0]
 
119
            operator = comment[1]
 
120
            text = comment[2]
 
121
            time = pickle.loads(comment[3])
 
122
            print time
 
123
            c.append(LegacyComment(id,operator,text,time))
119
124
        return c
120
125
 
121
126
cur = DB.cursor()
122
127
cur.execute('SELECT * FROM bans ORDER BY id desc LIMIT 1000')
123
 
#cur.execute('SELECT * from bans where id = 12489')
 
128
#cur.execute('SELECT * from bans where id = 16010')
124
129
result = cur.fetchall()
125
130
count  = 0
126
131