Commit 17785222188a8eea202d02036390b8214fd559f3

Authored by Luan
1 parent c6086633

Minor fixes and changes on attachments

src/proxy/migrations/0003_create_attachment_view.py
@@ -15,7 +15,7 @@ class Migration(DataMigration): @@ -15,7 +15,7 @@ class Migration(DataMigration):
15 cursor.execute(''' 15 cursor.execute('''
16 CREATE OR REPLACE VIEW attachment_view AS SELECT 16 CREATE OR REPLACE VIEW attachment_view AS SELECT
17 CONCAT(attachment.type, '/' , attachment.id, '/', attachment.filename) AS url, 17 CONCAT(attachment.type, '/' , attachment.id, '/', attachment.filename) AS url,
18 - attachment.type AS type, 18 + attachment.type AS used_by,
19 attachment.filename as filename, 19 attachment.filename as filename,
20 (SELECT LOWER(SUBSTRING(attachment.filename FROM '\w{2,3}$'))) AS mimetype, 20 (SELECT LOWER(SUBSTRING(attachment.filename FROM '\w{2,3}$'))) AS mimetype,
21 attachment.author as author, 21 attachment.author as author,
@@ -29,7 +29,7 @@ class Migration(DataMigration): @@ -29,7 +29,7 @@ class Migration(DataMigration):
29 connection = connections['trac'] 29 connection = connections['trac']
30 30
31 cursor = connection.cursor() 31 cursor = connection.cursor()
32 - cursor.execute('DROP VIEW attachment_view;') 32 + cursor.execute('DROP VIEW IF EXISTS attachment_view;')
33 33
34 models = { 34 models = {
35 u'proxy.attachment': { 35 u'proxy.attachment': {
src/proxy/models.py
@@ -8,7 +8,7 @@ from hitcount.models import HitCountModelMixin @@ -8,7 +8,7 @@ from hitcount.models import HitCountModelMixin
8 8
9 class Attachment(models.Model, HitCountModelMixin): 9 class Attachment(models.Model, HitCountModelMixin):
10 url = models.TextField(primary_key=True) 10 url = models.TextField(primary_key=True)
11 - type = models.TextField() 11 + used_by = models.TextField()
12 filename = models.TextField() 12 filename = models.TextField()
13 author = models.TextField(blank=True) 13 author = models.TextField(blank=True)
14 description = models.TextField(blank=True) 14 description = models.TextField(blank=True)