~bnrubin/bantrackertwo/devel

« back to all changes in this revision

Viewing changes to import.py

  • Committer: Benjamin Rubin
  • Date: 2009-09-02 02:14:31 UTC
  • Revision ID: bnrubin@romulus-20090902021431-02x226yec1d5sxal
- Cleaned up Event code and presentation
- Added basic Issue and Settings forms and presentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
 
1
#!/usr/bin/env python   
2
2
from django.core.management import setup_environ
3
3
import settings
4
4
import pickle
60
60
                    self.reason = comment.text
61
61
                    comment.enabled = False
62
62
        if self.mask == self.banmask and self.is_mark is not True and self.is_kick is not True:
63
 
            self.mask = 'unkown'
 
63
            self.mask = 'unk'
64
64
        print 'id: %s' % self.id
65
65
        print 'Mask: %s' % self.mask
66
66
        print 'Channel: %s' % self.channel
72
72
        print 'hostmask: %s' % self.mask
73
73
        print 'removal time: %s' % self.removal_time
74
74
        print 'Comments:'
75
 
        for c in self.comments:
76
 
            if c.enabled:
77
 
                print '%s: %s' % (c.time,c.text)
 
75
        for comment in self.comments:
 
76
            if comment.enabled:
 
77
                print '%s: %s' % (comment.time,comment.text)
78
78
                print '-------'            
79
79
        print '-----------------------------------------------------'
 
80
        
80
81
    def add(self):
81
82
        op,status = Operator.objects.get_or_create(host=self.operator)
82
83
        op.save()
102
103
                                       hostmask = self.mask, mask = self.banmask,
103
104
                                       removal_date = self.removal_time, removed_by = rem_op)
104
105
        event.save()
 
106
        print event.id
105
107
        for comment in self.comments:
106
108
            if comment.enabled:
107
109
                op,status = Operator.objects.get_or_create(host=comment.operator)
108
110
                op.save()
109
 
                c = Comment(content_object=event,text=comment.text,author=op,create_date=comment.time)
 
111
                c = Comment(content_object=event.event_ptr,text=comment.text,author=op,create_date=comment.time)
110
112
                c.save()
 
113
                print c.text
 
114
                print c.create_date
111
115
 
112
116
    def getComments(self,ban_id):
113
117
        cursor = DB.cursor()
124
128
        return c
125
129
 
126
130
cur = DB.cursor()
127
 
cur.execute('SELECT * FROM bans ORDER BY id desc LIMIT 1000')
 
131
cur.execute('SELECT * FROM bans ORDER BY id desc LIMIT 100')
128
132
#cur.execute('SELECT * from bans where id = 16010')
129
133
result = cur.fetchall()
130
134
count  = 0