diff --git a/colab/proxy/trac/data_api.py b/colab/proxy/trac/data_api.py index b2ebfb0..d648844 100644 --- a/colab/proxy/trac/data_api.py +++ b/colab/proxy/trac/data_api.py @@ -76,7 +76,8 @@ class TracDataAPI(ProxyDataAPI): revision.message = line['message'] revision.description = revision.message revision.created = self.get_revision_created(cursor, line['rev']) - revision.repository_name = repository_dict[line['repos']] + revision.repository_name = line['repos'] + revision.save() def fetch_data_ticket(self, empty_cursor): """ This method is responsible for seeking the ticket data in @@ -106,16 +107,24 @@ class TracDataAPI(ProxyDataAPI): ticket.reporter = line['reporter'] ticket.status = line['status'] ticket.tag = ticket.status - ticket.keywords = line['keywords'] - ticket.owner = line['owner'] - ticket.resolution = line['resolution'] + if line['keywords']: + ticket.keywords = line['keywords'] + if line['owner']: + ticket.owner = line['owner'] + else: + ticket.owner = 'Anonymous' + if line['resolution']: + ticket.resolution = line['resolution'] + else: + ticket.resolution = 'no resolution' ticket.author = ticket.reporter ticket.created = self.get_ticket_created(cursor, line['id']) ticket.modified = self.get_ticket_modified(cursor, line['id']) - ticket.modified_by = ticket.author if line['reporter'] not in collaborators: collaborators.append(line['reporter']) ticket.collaborators = collaborators + ticket.update_user(ticket.author) + ticket.save() def fetch_data_wiki(self, empty_cursor): """ This method is responsible for seeking the wiki data in @@ -136,7 +145,7 @@ class TracDataAPI(ProxyDataAPI): for line in wiki_dict: wiki.update_user(line['author']) wiki.title = line['name'] - wiki.text = line['text'] + wiki.wiki_text = line['text'] wiki.author = line['author'] if line['author'] not in collaborators: collaborators.append(line['author']) diff --git a/colab/proxy/trac/models.py b/colab/proxy/trac/models.py index ac92c13..aa775f8 100644 --- a/colab/proxy/trac/models.py +++ b/colab/proxy/trac/models.py @@ -49,7 +49,6 @@ class Attachment(models.Model, HitCounterModelMixin): except User.DoesNotExist: return None - class Revision(models.Model, HitCounterModelMixin): update_field = 'created' icon_name = 'align-right' @@ -78,7 +77,7 @@ class Revision(models.Model, HitCounterModelMixin): return None -class Ticket(models.Model, HitCounterModelMixin): +class Ticket(Collaboration, HitCounterModelMixin): icon_name = 'tag' type = 'ticket' summary = models.TextField(blank=True) @@ -96,7 +95,6 @@ class Ticket(models.Model, HitCounterModelMixin): collaborators = models.TextField(blank=True) created = models.DateTimeField(blank=True, null=True) modified = models.DateTimeField(blank=True, null=True) - modified_by = models.TextField(blank=True) owner = models.TextField(blank=True) resolution = models.TextField(blank=True) diff --git a/colab/proxy/trac/templates/search/indexes/trac/attachment_text.txt b/colab/proxy/trac/templates/search/indexes/trac/attachment_text.txt new file mode 100644 index 0000000..9b22bae --- /dev/null +++ b/colab/proxy/trac/templates/search/indexes/trac/attachment_text.txt @@ -0,0 +1,15 @@ +{{ object.filename }} +{{ object.filename|slugify }} +{{ object.description }} +{{ object.description|slugify }} +{{ object.used_by }} +{{ object.mimetype }} +{{ object.get_author.get_full_name }} + +{% for k, v in extracted.metadata.items %} + {% for val in v %} + {{ k }}: {{ val|safe }} + {% endfor %} +{% endfor %} + +{{ extracted.contents|striptags|safe }} diff --git a/colab/proxy/trac/templates/search/indexes/trac/revision_text.txt b/colab/proxy/trac/templates/search/indexes/trac/revision_text.txt new file mode 100644 index 0000000..64cca83 --- /dev/null +++ b/colab/proxy/trac/templates/search/indexes/trac/revision_text.txt @@ -0,0 +1,8 @@ +{{ object.repository_name }} +{{ object.repository_name|slugify }} +{{ object.rev }} +{{ object.rev|slugify }} +{% firstof object.get_author.get_full_name object.author %} +{% firstof object.get_author.get_full_name|slugify object.author|slugify %} +{{ object.message }} +{{ object.message|slugify }} diff --git a/colab/proxy/trac/templates/search/indexes/trac/ticket_text.txt b/colab/proxy/trac/templates/search/indexes/trac/ticket_text.txt new file mode 100644 index 0000000..93d199e --- /dev/null +++ b/colab/proxy/trac/templates/search/indexes/trac/ticket_text.txt @@ -0,0 +1,20 @@ +{{ object.summary }} +{{ object.summary|slugify }} +{{ object.description }} +{{ object.description|slugify }} +{{ object.milestone }} +{{ object.milestone|slugify }} +{{ object.component|slugify }} +{{ object.version }} +{{ object.severity }} +{{ object.severity|slugify }} +{{ object.reporter }} +{{ object.reporter|slugify }} +{% firstof object.get_author.get_fullname or object.author %} +{% firstof object.get_author.get_fullname|slugify or object.author|slugify %} +{{ object.status }} +{{ object.status|slugify }} +{{ object.keywords }} +{{ object.keywords|slugify }} +{{ object.collaborators }} +{{ object.collaborators|slugify }} diff --git a/docs/source/user.rst b/docs/source/user.rst index ff92176..7985e0e 100644 --- a/docs/source/user.rst +++ b/docs/source/user.rst @@ -30,6 +30,8 @@ Since Trac already installed: To enable Trac plugin must first configure the trac database in /etc/colab/settings.yml: +1. vim /etc/colab/settings.yaml + .. code-block:: yaml DATABASES: @@ -39,12 +41,12 @@ To enable Trac plugin must first configure the trac database in /etc/colab/setti NAME: colab USER: colab PASSWORD: colab - trac: - ENGINE: django.db.backends.postgresql_psycopg2 - HOST: localhost - NAME: trac - USER: colab - PASSWORD: colab + trac: + ENGINE: django.db.backends.postgresql_psycopg2 + HOST: localhost + NAME: trac + USER: colab + PASSWORD: colab - Yet this file uncomment in PROXIED_APPS the Trac: @@ -68,16 +70,16 @@ To enable Trac plugin must first configure the trac database in /etc/colab/setti .. code-block:: sh - # Since you are in the folder colab + # Since you are in the folder colab $ workon colab - $ colab-admin makemigrations trac - $ colab-admin migrate + $ colab-admin makemigrations + $ colab-admin migrate trac - Finally, just import the Trac data (may take a few minutes): .. code-block:: sh - # Since you are in the folder colab + # Since you are in the folder colab $ colab-admin import_proxy_data Settings -- libgit2 0.21.2