Commit 15d11378641b6c5ca529fd3b14c0b369ee973688

Authored by carol15022
Committed by Sergio Oliveira
1 parent 6961d1c2
Exists in trac_indexing

Fixing attachment according to Haystack

Signed-off-by: Thiago Ribeiro <thiagitosouza@hotmail.com>
colab/proxy/trac/data_api.py
@@ -13,7 +13,9 @@ class TracDataAPI(ProxyDataAPI): @@ -13,7 +13,9 @@ class TracDataAPI(ProxyDataAPI):
13 cursor = connection.cursor() 13 cursor = connection.cursor()
14 self.fetch_data_wiki(cursor) 14 self.fetch_data_wiki(cursor)
15 self.fetch_data_attachment(cursor) 15 self.fetch_data_attachment(cursor)
16 - 16 + self.fetch_data_ticket(cursor)
  17 + self.fetch_data_revision(cursor)
  18 +
17 def fetch_data_attachment(self, cursor): 19 def fetch_data_attachment(self, cursor):
18 attachment = Attachment() 20 attachment = Attachment()
19 cursor.execute(''' SELECT * from attachment; ''') 21 cursor.execute(''' SELECT * from attachment; ''')
@@ -22,13 +24,14 @@ class TracDataAPI(ProxyDataAPI): @@ -22,13 +24,14 @@ class TracDataAPI(ProxyDataAPI):
22 attachment.description = line['description'] 24 attachment.description = line['description']
23 attachment.id = line['attach_id'] 25 attachment.id = line['attach_id']
24 attachment.filename = line['filemame'] 26 attachment.filename = line['filemame']
  27 + attachment.title = attachment.filename
25 attachment.size = line['size'] 28 attachment.size = line['size']
26 attachment.author = line['author'] 29 attachment.author = line['author']
27 attachment.used_by = line['type'] 30 attachment.used_by = line['type']
28 attachment.url = attachment.user_by + "/" + attachment.id \ 31 attachment.url = attachment.user_by + "/" + attachment.id \
29 + "/" + attachment.filename 32 + "/" + attachment.filename
30 local_time = line['time']/1000000 33 local_time = line['time']/1000000
31 - attachment.created = time.strftime('%Y-%m-%d %H:%M:%S', 34 + attachment.modified = time.strftime('%Y-%m-%d %H:%M:%S',
32 time.localtime(local_time)) 35 time.localtime(local_time))
33 if match("\.(\w+)$", attachment.filename): 36 if match("\.(\w+)$", attachment.filename):
34 attachment.mimetype = attachment.filename.lower() 37 attachment.mimetype = attachment.filename.lower()
colab/proxy/trac/models.py
@@ -13,13 +13,16 @@ from django.utils.translation import ugettext_lazy as _ @@ -13,13 +13,16 @@ from django.utils.translation import ugettext_lazy as _
13 13
14 14
15 class Attachment(models.Model, HitCounterModelMixin): 15 class Attachment(models.Model, HitCounterModelMixin):
  16 + type = 'attachment'
  17 + icon_name = 'file'
16 url = models.TextField(primary_key=True) 18 url = models.TextField(primary_key=True)
17 attach_id = models.TextField() 19 attach_id = models.TextField()
18 used_by = models.TextField() 20 used_by = models.TextField()
19 filename = models.TextField() 21 filename = models.TextField()
20 author = models.TextField(blank=True) 22 author = models.TextField(blank=True)
  23 + title = models.TextField(blank=True)
21 description = models.TextField(blank=True) 24 description = models.TextField(blank=True)
22 - created = models.DateTimeField(blank=True) 25 + modified = models.DateTimeField(blank=True)
23 mimetype = models.TextField(blank=True) 26 mimetype = models.TextField(blank=True)
24 size = models.IntegerField(blank=True) 27 size = models.IntegerField(blank=True)
25 28