diff --git a/colab/management/commands/initconfig.py b/colab/management/commands/initconfig.py
index 02b2ca8..929b318 100644
--- a/colab/management/commands/initconfig.py
+++ b/colab/management/commands/initconfig.py
@@ -73,45 +73,6 @@ LOGGING = {{
}},
}},
}}
-
-
-## Gitlab plugin - Put this in plugins.d/gitlab.py to actiate ##
-# from django.utils.translation import ugettext_lazy as _
-# from colab.plugins.utils.menu import colab_url_factory
-#
-# name = 'colab.plugins.gitlab'
-# verbose_name = 'Gitlab Plugin'
-#
-# upstream = 'localhost'
-# #middlewares = []
-#
-# urls = {{
-# 'include': 'colab.plugins.gitlab.urls',
-# 'namespace': 'gitlab',
-# 'prefix': 'gitlab',
-# }}
-#
-# menu_title = _('Code')
-#
-# url = colab_url_factory('gitlab')
-#
-# menu_urls = (
-# url(display=_('Public Projects'), viewname='gitlab',
-# kwargs={{'path': '/public/projects'}}, auth=False),
-# url(display=_('Profile'), viewname='gitlab',
-# kwargs={{'path': '/profile'}}, auth=True),
-# url(display=_('New Project'), viewname='gitlab',
-# kwargs={{'path': '/projects/new'}}, auth=True),
-# url(display=_('Projects'), viewname='gitlab',
-# kwargs={{'path': '/dashboard/projects'}}, auth=True),
-# url(display=_('Groups'), viewname='gitlab',
-# kwargs={{'path': '/profile/groups'}}, auth=True),
-# url(display=_('Issues'), viewname='gitlab',
-# kwargs={{'path': '/dashboard/issues'}}, auth=True),
-# url(display=_('Merge Requests'), viewname='gitlab',
-# kwargs={{'path': '/merge_requests'}}, auth=True),
-#
-# )
"""
diff --git a/colab/plugins/gitlab/__init__.py b/colab/plugins/gitlab/__init__.py
deleted file mode 100644
index a3f8019..0000000
--- a/colab/plugins/gitlab/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-default_app_config = 'colab.plugins.gitlab.apps.GitlabPluginAppConfig'
diff --git a/colab/plugins/gitlab/apps.py b/colab/plugins/gitlab/apps.py
deleted file mode 100644
index 33bdb8b..0000000
--- a/colab/plugins/gitlab/apps.py
+++ /dev/null
@@ -1,18 +0,0 @@
-
-from ..utils.apps import ColabPluginAppConfig
-from colab.plugins.gitlab.tasks import handling_method
-from colab.signals.signals import register_signal, connect_signal
-
-
-class GitlabPluginAppConfig(ColabPluginAppConfig):
- name = 'colab.plugins.gitlab'
- verbose_name = 'Gitlab Plugin'
- short_name = 'gitlab'
-
- signals_list = ['gitlab_create_project']
-
- def register_signal(self):
- register_signal(self.short_name, self.signals_list)
-
- def connect_signal(self):
- connect_signal(self.signals_list[0], self.short_name, handling_method)
diff --git a/colab/plugins/gitlab/data_importer.py b/colab/plugins/gitlab/data_importer.py
deleted file mode 100644
index 50b39b4..0000000
--- a/colab/plugins/gitlab/data_importer.py
+++ /dev/null
@@ -1,188 +0,0 @@
-import json
-import urllib
-import urllib2
-import logging
-
-from dateutil.parser import parse
-
-from django.db.models.fields import DateTimeField
-from colab.plugins.data import PluginDataImporter
-
-from .models import (GitlabProject, GitlabMergeRequest,
- GitlabComment, GitlabIssue, GitlabGroup)
-
-
-LOGGER = logging.getLogger('colab.plugin.gitlab')
-
-
-class GitlabDataImporter(PluginDataImporter):
- app_label = 'gitlab'
-
- def get_request_url(self, path, **kwargs):
- upstream = self.config.get('upstream')
- kwargs['private_token'] = self.config.get('private_token')
- params = urllib.urlencode(kwargs)
-
- if upstream[-1] == '/':
- upstream = upstream[:-1]
-
- return u'{}{}?{}'.format(upstream, path, params)
-
- def get_json_data(self, api_url, page, pages=1000):
- url = self.get_request_url(api_url, per_page=pages,
- page=page)
-
- try:
- data = urllib2.urlopen(url, timeout=10)
- json_data = json.load(data)
- except urllib2.URLError:
- LOGGER.exception("Connection timeout: " + url)
- json_data = []
-
- return json_data
-
- def fill_object_data(self, element, _object):
- for field in _object._meta.fields:
- try:
- if field.name == "user":
- _object.update_user(
- element["author"]["username"])
- continue
- if field.name == "project":
- _object.project_id = element["project_id"]
- continue
-
- if isinstance(field, DateTimeField):
- value = parse(element[field.name])
- else:
- value = element[field.name]
-
- setattr(_object, field.name, value)
- except KeyError:
- continue
-
- return _object
-
- def fetch(self, url, gitlab_class):
- page = 1
- obj_list = []
-
- while True:
- json_data = self.get_json_data(url, page)
- page = page + 1
-
- if not len(json_data):
- break
-
- for element in json_data:
- obj = gitlab_class()
- self.fill_object_data(element, obj)
- obj_list.append(obj)
-
- return obj_list
-
- def fetch_comments(self, url, parent_class, issue_comment):
- all_comments = []
- all_parent_objects = parent_class.objects.all()
-
- for parent_obj in all_parent_objects:
- page = 1
- while True:
- formated_url = url.format(parent_obj.project_id, parent_obj.id)
- json_data = self.get_json_data(formated_url, page)
- page = page + 1
-
- if len(json_data) == 0:
- break
-
- for element in json_data:
- single_comment = GitlabComment()
- self.fill_object_data(element, single_comment)
- single_comment.project = parent_obj.project
- single_comment.issue_comment = issue_comment
- single_comment.parent_id = parent_obj.id
- all_comments.append(single_comment)
-
- return all_comments
-
- def fetch_projects(self):
- return self.fetch('/api/v3/projects/all', GitlabProject)
-
- def fetch_groups(self):
- return self.fetch('/api/v3/groups', GitlabGroup)
-
- def fetch_merge_request(self, projects):
- merge_requests = []
- for project in projects:
- url = '/api/v3/projects/{}/merge_requests'.format(project.id)
- merge_requests.extend(self.fetch(url, GitlabMergeRequest))
- return merge_requests
-
- def fetch_issue(self, projects):
- issues = []
- for project in projects:
- url = '/api/v3/projects/{}/issues'.format(project.id)
- issues.extend(self.fetch(url, GitlabIssue))
- return issues
-
- def fetch_all_comments(self):
- all_comments = []
- all_comments.extend(self.fetch_comments_mr())
- all_comments.extend(self.fetch_comments_issues())
-
- return all_comments
-
- def fetch_comments_mr(self):
- url = '/api/v3/projects/{}/merge_requests/{}/notes'
- return self.fetch_comments(url, GitlabMergeRequest, False)
-
- def fetch_comments_issues(self):
- url = '/api/v3/projects/{}/issues/{}/notes'
- return self.fetch_comments(url, GitlabIssue, True)
-
-
-class GitlabProjectImporter(GitlabDataImporter):
-
- def fetch_data(self):
- LOGGER.info("Importing Projects")
- projects = self.fetch_projects()
- for datum in projects:
- datum.save()
-
-
-class GitlabGroupImporter(GitlabDataImporter):
-
- def fetch_data(self):
- LOGGER.info("Importing Group")
- groups_list = self.fetch_groups()
- for datum in groups_list:
- datum.save()
-
-
-class GitlabMergeRequestImporter(GitlabDataImporter):
-
- def fetch_data(self):
- LOGGER.info("Importing Merge Requests")
- projects = GitlabProject.objects.all()
- merge_request_list = self.fetch_merge_request(projects)
- for datum in merge_request_list:
- datum.save()
-
-
-class GitlabIssueImporter(GitlabDataImporter):
-
- def fetch_data(self):
- LOGGER.info("Importing Issues")
- projects = GitlabProject.objects.all()
- issue_list = self.fetch_issue(projects)
- for datum in issue_list:
- datum.save()
-
-
-class GitlabCommentImporter(GitlabDataImporter):
-
- def fetch_data(self):
- LOGGER.info("Importing Comments")
- comments_list = self.fetch_all_comments()
- for datum in comments_list:
- datum.save()
diff --git a/colab/plugins/gitlab/diazo.xml b/colab/plugins/gitlab/diazo.xml
deleted file mode 100644
index 34ffbbe..0000000
--- a/colab/plugins/gitlab/diazo.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/colab/plugins/gitlab/fixtures/__init__.py b/colab/plugins/gitlab/fixtures/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/colab/plugins/gitlab/fixtures/__init__.py
+++ /dev/null
diff --git a/colab/plugins/gitlab/fixtures/gitlab_associations.json b/colab/plugins/gitlab/fixtures/gitlab_associations.json
deleted file mode 100644
index f09ab55..0000000
--- a/colab/plugins/gitlab/fixtures/gitlab_associations.json
+++ /dev/null
@@ -1,100 +0,0 @@
-[
-{
- "fields": {
- "last_name": "Administrator",
- "webpage": "",
- "twitter": "",
- "is_staff": true,
- "user_permissions": [],
- "date_joined": "2015-01-28T12:34:58.770Z",
- "google_talk": "",
- "first_name": "Admin",
- "is_superuser": true,
- "last_login": "2015-08-24T14:33:28.802Z",
- "verification_hash": null,
- "role": "",
- "email": "admin@mail.com",
- "username": "admin",
- "bio": "",
- "needs_update": true,
- "is_active": true,
- "facebook": "",
- "groups": [],
- "password": "pbkdf2_sha256$15000$sWnvfYpB8ec4$7dEFg6vSSGPnpEmfRelJ12zkiwacGx9aXx8/8ZFWBSI=",
- "institution": "",
- "github": "",
- "modified": "2015-01-28T12:45:27.375Z"
- },
- "model": "accounts.user",
- "pk": 1
-},
-{
- "fields": {
- "last_name": "user",
- "webpage": null,
- "twitter": null,
- "is_staff": false,
- "user_permissions": [],
- "date_joined": "2015-08-24T14:33:55.827Z",
- "google_talk": null,
- "first_name": "user",
- "is_superuser": false,
- "last_login": "2015-08-24T14:33:55.827Z",
- "verification_hash": null,
- "role": null,
- "email": "user@teste.com",
- "username": "user",
- "bio": null,
- "needs_update": true,
- "is_active": true,
- "facebook": null,
- "groups": [],
- "password": "pbkdf2_sha256$15000$9ew6EvFvAIhI$147annuMjzt7em5IRh+3k7wcl7rZ0xjBPSmbUZDdxFo=",
- "institution": null,
- "github": null,
- "modified": "2015-08-24T14:33:55.893Z"
- },
- "model": "accounts.user",
- "pk": 2
-},
-{
- "fields": {
- "last_activity_at": "2015-06-08T19:28:27.148Z",
- "description": "Colab source code",
- "name_with_namespace": "Software Publico / Colab",
- "created_at": "2014-09-26T14:58:52.491Z",
- "path_with_namespace": "softwarepublico/colab",
- "public": true,
- "name": "Colab"
- },
- "model": "gitlab.gitlabproject",
- "pk": 14
-},
-{
- "fields": {
- "target_branch": "master",
- "description": "",
- "source_branch": "settings_fix",
- "created_at": "2014-10-24T12:05:55.659Z",
- "title": "Settings fix",
- "project": 14,
- "iid": 1,
- "state": "merged",
- "user": null
- },
- "model": "gitlab.gitlabmergerequest",
- "pk": 7
-},
-{
- "fields": {
- "description": "Remove the main SPB logo from the homepage",
- "title": "Remove the SPB central logo",
- "created_at": "2014-10-07T17:40:27.625Z",
- "project": 14,
- "state": "closed",
- "user": null
- },
- "model": "gitlab.gitlabissue",
- "pk": 2
-}
-]
\ No newline at end of file
diff --git a/colab/plugins/gitlab/fixtures/test_gitlab_data.json b/colab/plugins/gitlab/fixtures/test_gitlab_data.json
deleted file mode 100644
index 776bd3a..0000000
--- a/colab/plugins/gitlab/fixtures/test_gitlab_data.json
+++ /dev/null
@@ -1,146 +0,0 @@
-[
-{
- "fields": {
- "last_name": "COLAB",
- "webpage": null,
- "twitter": "usertestcolab",
- "is_staff": false,
- "user_permissions": [],
- "date_joined": "2015-08-28T18:00:59.753Z",
- "google_talk": null,
- "first_name": "USERtestCoLaB",
- "is_superuser": false,
- "last_login": "2015-08-28T18:00:59.753Z",
- "verification_hash": null,
- "role": null,
- "email": "usertest@colab.com.br",
- "username": "usertestcolab",
- "bio": null,
- "needs_update": true,
- "is_active": true,
- "facebook": "usertestcolab",
- "groups": [],
- "password": "pbkdf2_sha256$15000$unxhDDCB1vsw$Esdx3tQ2ayPW08/SImQzbBeRiK8Hoa6fBZhw3dMQga8=",
- "institution": null,
- "github": null,
- "modified": "2015-08-28T18:00:59.996Z"
- },
- "model": "accounts.user",
- "pk": 1
-},
-{
- "fields": {
- "last_activity_at": "2015-08-28T18:01:28.469Z",
- "description": "",
- "name_with_namespace": "Software Public / Colab",
- "created_at": "2015-08-28T18:01:28.467Z",
- "path_with_namespace": "softwarepublico/colab",
- "public": true,
- "name": "colab"
- },
- "model": "gitlab.gitlabproject",
- "pk": 1
-},
-{
- "fields": {
- "last_activity_at": "2015-08-28T18:01:28.491Z",
- "description": "",
- "name_with_namespace": "Software Public / ColabInc",
- "created_at": "2015-08-28T18:01:28.489Z",
- "path_with_namespace": "softwarepublico/colabinc",
- "public": true,
- "name": "colabinc"
- },
- "model": "gitlab.gitlabproject",
- "pk": 2
-},
-{
- "fields": {
- "path": "softwarepublico",
- "name": "Software Public",
- "owner_id": 1
- },
- "model": "gitlab.gitlabgroup",
- "pk": 1
-},
-{
- "fields": {
- "target_branch": "",
- "description": "Merge request for plugin support",
- "source_branch": "",
- "created_at": "2015-08-28T18:01:28.512Z",
- "title": "Include plugin support",
- "project": 1,
- "iid": 1,
- "state": "Closed",
- "user": 1
- },
- "model": "gitlab.gitlabmergerequest",
- "pk": 1
-},
-{
- "fields": {
- "target_branch": "",
- "description": "Merge request for test support",
- "source_branch": "",
- "created_at": "2015-08-28T18:01:28.561Z",
- "title": "Include test support",
- "project": 2,
- "iid": 1,
- "state": "Closed",
- "user": 1
- },
- "model": "gitlab.gitlabmergerequest",
- "pk": 2
-},
-{
- "fields": {
- "description": "Issue reported to colab",
- "title": "Issue for colab",
- "created_at": "2015-08-28T18:01:28.590Z",
- "project": 1,
- "iid": 1,
- "state": "Open",
- "user": 1
- },
- "model": "gitlab.gitlabissue",
- "pk": 1
-},
-{
- "fields": {
- "description": "Issue reported to colab",
- "title": "Issue for colab",
- "created_at": "2015-08-28T18:01:28.628Z",
- "project": 2,
- "iid": 1,
- "state": "Open",
- "user": 1
- },
- "model": "gitlab.gitlabissue",
- "pk": 2
-},
-{
- "fields": {
- "body": "Comment to merge request",
- "created_at": "2015-08-28T18:01:28.663Z",
- "issue_comment": false,
- "project": 1,
- "parent_id": 1,
- "user": 1
- },
- "model": "gitlab.gitlabcomment",
- "pk": 1
-},
-{
- "fields": {
- "body": "Comment to issue",
- "created_at": "2015-08-28T18:01:28.693Z",
- "issue_comment": true,
- "project": 1,
- "parent_id": 1,
- "user": 1
- },
- "model": "gitlab.gitlabcomment",
- "pk": 2
-}
-]
diff --git a/colab/plugins/gitlab/migrations/0001_initial.py b/colab/plugins/gitlab/migrations/0001_initial.py
deleted file mode 100644
index bdb4508..0000000
--- a/colab/plugins/gitlab/migrations/0001_initial.py
+++ /dev/null
@@ -1,134 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
-import django.db.models.deletion
-import hitcounter.models
-from django.conf import settings
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- migrations.swappable_dependency(settings.AUTH_USER_MODEL),
- ]
-
- operations = [
- migrations.CreateModel(
- name='GitlabComment',
- fields=[
- ('id', models.IntegerField(serialize=False, primary_key=True)),
- ('body', models.TextField()),
- ('created_at', models.DateTimeField(null=True, blank=True)),
- ('issue_comment', models.BooleanField(default=True)),
- ('parent_id', models.IntegerField(null=True)),
- ],
- options={
- 'verbose_name': 'Gitlab Comments',
- 'verbose_name_plural': 'Gitlab Comments',
- },
- bases=(models.Model,),
- ),
- migrations.CreateModel(
- name='GitlabGroup',
- fields=[
- ('id', models.IntegerField(serialize=False, primary_key=True)),
- ('name', models.CharField(max_length=100)),
- ('path', models.CharField(max_length=100)),
- ('owner_id', models.IntegerField(null=True)),
- ],
- options={
- 'verbose_name': 'Gitlab Group',
- 'verbose_name_plural': 'Gitlab Groups',
- },
- bases=(models.Model,),
- ),
- migrations.CreateModel(
- name='GitlabIssue',
- fields=[
- ('id', models.IntegerField(serialize=False, primary_key=True)),
- ('iid', models.IntegerField(null=True)),
- ('title', models.TextField()),
- ('description', models.TextField()),
- ('state', models.TextField()),
- ('created_at', models.DateTimeField(null=True, blank=True)),
- ],
- options={
- 'verbose_name': 'Gitlab Issue',
- 'verbose_name_plural': 'Gitlab Issues',
- },
- bases=(models.Model,),
- ),
- migrations.CreateModel(
- name='GitlabMergeRequest',
- fields=[
- ('id', models.IntegerField(serialize=False, primary_key=True)),
- ('iid', models.IntegerField(null=True)),
- ('target_branch', models.TextField()),
- ('source_branch', models.TextField()),
- ('description', models.TextField()),
- ('title', models.TextField()),
- ('state', models.TextField()),
- ('created_at', models.DateTimeField(null=True, blank=True)),
- ],
- options={
- 'verbose_name': 'Gitlab Merge Request',
- 'verbose_name_plural': 'Gitlab Merge Requests',
- },
- bases=(models.Model,),
- ),
- migrations.CreateModel(
- name='GitlabProject',
- fields=[
- ('id', models.IntegerField(serialize=False, primary_key=True)),
- ('description', models.TextField()),
- ('public', models.BooleanField(default=True)),
- ('name', models.TextField()),
- ('name_with_namespace', models.TextField()),
- ('created_at', models.DateTimeField(blank=True)),
- ('last_activity_at', models.DateTimeField(blank=True)),
- ('path_with_namespace', models.TextField(null=True, blank=True)),
- ],
- options={
- 'verbose_name': 'Gitlab Project',
- 'verbose_name_plural': 'Gitlab Projects',
- },
- bases=(models.Model, hitcounter.models.HitCounterModelMixin),
- ),
- migrations.AddField(
- model_name='gitlabmergerequest',
- name='project',
- field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='gitlab.GitlabProject', null=True),
- preserve_default=True,
- ),
- migrations.AddField(
- model_name='gitlabmergerequest',
- name='user',
- field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True),
- preserve_default=True,
- ),
- migrations.AddField(
- model_name='gitlabissue',
- name='project',
- field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='gitlab.GitlabProject', null=True),
- preserve_default=True,
- ),
- migrations.AddField(
- model_name='gitlabissue',
- name='user',
- field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True),
- preserve_default=True,
- ),
- migrations.AddField(
- model_name='gitlabcomment',
- name='project',
- field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='gitlab.GitlabProject', null=True),
- preserve_default=True,
- ),
- migrations.AddField(
- model_name='gitlabcomment',
- name='user',
- field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True),
- preserve_default=True,
- ),
- ]
diff --git a/colab/plugins/gitlab/migrations/__init__.py b/colab/plugins/gitlab/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/colab/plugins/gitlab/migrations/__init__.py
+++ /dev/null
diff --git a/colab/plugins/gitlab/models.py b/colab/plugins/gitlab/models.py
deleted file mode 100644
index 9457a49..0000000
--- a/colab/plugins/gitlab/models.py
+++ /dev/null
@@ -1,177 +0,0 @@
-from django.db import models
-from django.utils.translation import ugettext_lazy as _
-from colab.plugins.utils.models import Collaboration
-from hitcounter.models import HitCounterModelMixin
-
-
-class GitlabProject(models.Model, HitCounterModelMixin):
-
- id = models.IntegerField(primary_key=True)
- description = models.TextField()
- public = models.BooleanField(default=True)
- name = models.TextField()
- name_with_namespace = models.TextField()
- created_at = models.DateTimeField(blank=True)
- last_activity_at = models.DateTimeField(blank=True)
- path_with_namespace = models.TextField(blank=True, null=True)
-
- @property
- def namespace(self):
- return self.path_with_namespace.split('/')[0]
-
- @property
- def url(self):
- return u'/gitlab/{}'.format(self.path_with_namespace)
-
- class Meta:
- verbose_name = _('Gitlab Project')
- verbose_name_plural = _('Gitlab Projects')
-
-
-class GitlabGroup(models.Model):
- id = models.IntegerField(primary_key=True)
- name = models.CharField(max_length=100)
- path = models.CharField(max_length=100)
- owner_id = models.IntegerField(null=True)
-
- def __unicode__(self):
- return u'{}'.format(self.path)
-
- @property
- def projects(self):
- projects = GitlabProject.objects.all()
- result = list()
- for project in projects:
- if self.path in project.namespace:
- result.append(project)
- return result
-
- @property
- def url(self):
- return u'/gitlab/groups/{}'.format(self.path)
-
- class Meta:
- verbose_name = _('Gitlab Group')
- verbose_name_plural = _('Gitlab Groups')
-
-
-class GitlabMergeRequest(Collaboration):
-
- id = models.IntegerField(primary_key=True)
- iid = models.IntegerField(null=True)
- target_branch = models.TextField()
- source_branch = models.TextField()
- project = models.ForeignKey(GitlabProject, null=True,
- on_delete=models.SET_NULL)
- description = models.TextField()
- title = models.TextField()
- state = models.TextField()
- created_at = models.DateTimeField(blank=True, null=True)
-
- @property
- def modified(self):
- return self.created_at
-
- @property
- def tag(self):
- return self.state
-
- type = u'merge_request'
- icon_name = u'file'
-
- @property
- def url(self):
- return u'/gitlab/{}/merge_requests/{}'.format(
- self.project.path_with_namespace, self.iid)
-
- def get_author(self):
- return self.user
-
- class Meta:
- verbose_name = _('Gitlab Merge Request')
- verbose_name_plural = _('Gitlab Merge Requests')
-
-
-class GitlabIssue(Collaboration):
-
- id = models.IntegerField(primary_key=True)
- iid = models.IntegerField(null=True)
- project = models.ForeignKey(GitlabProject, null=True,
- on_delete=models.SET_NULL)
- title = models.TextField()
- description = models.TextField()
-
- state = models.TextField()
- created_at = models.DateTimeField(blank=True, null=True)
-
- icon_name = u'align-right'
- type = u'gitlab_issue'
-
- @property
- def modified(self):
- return self.created_at
-
- @property
- def url(self):
- return u'/gitlab/{}/issues/{}'.format(
- self.project.path_with_namespace, self.iid)
-
- class Meta:
- verbose_name = _('Gitlab Issue')
- verbose_name_plural = _('Gitlab Issues')
-
-
-class GitlabComment(Collaboration):
-
- id = models.IntegerField(primary_key=True)
- body = models.TextField()
- created_at = models.DateTimeField(blank=True, null=True)
- issue_comment = models.BooleanField(default=True)
-
- project = models.ForeignKey(GitlabProject, null=True,
- on_delete=models.SET_NULL)
-
- parent_id = models.IntegerField(null=True)
- type = u'comment'
-
- @property
- def modified(self):
- return self.created_at
-
- @property
- def title(self):
- if self.issue_comment:
- issue = GitlabIssue.objects.get(id=self.parent_id)
- return issue.title
- else:
- merge_request = GitlabMergeRequest.objects.get(id=self.parent_id)
- return merge_request.title
-
- icon_name = u'align-right'
-
- @property
- def description(self):
- return self.body
-
- @property
- def tag(self):
- if self.issue_comment:
- issue = GitlabIssue.objects.get(id=self.parent_id)
- return issue.state
- else:
- merge_request = GitlabMergeRequest.objects.get(id=self.parent_id)
- return merge_request.state
-
- @property
- def url(self):
- if self.issue_comment:
- url_str = u'/gitlab/{}/issues/{}#notes_{}'
- else:
- url_str = u'/gitlab/{}/merge_requests/{}#notes_{}'
-
- return url_str.format(self.project.path_with_namespace,
- self.parent_id, self.id)
-
- class Meta:
- verbose_name = _('Gitlab Comments')
- verbose_name_plural = _('Gitlab Comments')
diff --git a/colab/plugins/gitlab/search_indexes.py b/colab/plugins/gitlab/search_indexes.py
deleted file mode 100644
index 01f1b4a..0000000
--- a/colab/plugins/gitlab/search_indexes.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import string
-
-from haystack import indexes
-from haystack.utils import log as logging
-
-from .models import (GitlabProject, GitlabMergeRequest,
- GitlabIssue, GitlabComment)
-
-
-logger = logging.getLogger('haystack')
-
-# The string maketrans always return a string encoded with latin1
-# http://stackoverflow.com/questions/1324067/how-do-i-get-str-translate-to-work-with-unicode-strings
-table = string.maketrans(
- string.punctuation,
- '.' * len(string.punctuation)
-).decode('latin1')
-
-
-class GitlabProjectIndex(indexes.SearchIndex, indexes.Indexable):
- text = indexes.CharField(document=True, use_template=False, stored=False)
- title = indexes.CharField(model_attr='name')
- description = indexes.CharField(model_attr='description', null=True)
- tag = indexes.CharField()
- url = indexes.CharField(model_attr='url', indexed=False)
- icon_name = indexes.CharField()
- type = indexes.CharField()
- created = indexes.DateTimeField(model_attr='created_at', null=True)
-
- def prepare_tag(self, obj):
- return "{}".format(obj.name_with_namespace.split('/')[0].strip())
-
- def prepare_icon_name(self, obj):
- return u'file'
-
- def get_ful_name(self):
- self.objs.name
-
- def get_model(self):
- return GitlabProject
-
- def prepare_type(self, obj):
- return u'gitlab'
-
-
-class GitlabMergeRequestIndex(indexes.SearchIndex, indexes.Indexable):
-
- text = indexes.CharField(document=True, use_template=False, stored=False)
- title = indexes.CharField(model_attr='title')
- description = indexes.CharField(model_attr='description')
- tag = indexes.CharField(model_attr='state')
- url = indexes.CharField(model_attr='url', indexed=False)
- icon_name = indexes.CharField()
- type = indexes.CharField(model_attr='type')
-
- modified_by = indexes.CharField(model_attr='modified_by', null=True)
- modified_by_url = indexes.CharField(model_attr='modified_by_url',
- null=True)
- modified = indexes.DateTimeField(model_attr='created_at', null=True)
-
- def get_model(self):
- return GitlabMergeRequest
-
- def prepare_icon_name(self, obj):
- return u'file'
-
- def prepare_type(self, obj):
- return u'merge_request'
-
-
-class GitlabIssueIndex(indexes.SearchIndex, indexes.Indexable):
-
- text = indexes.CharField(document=True, use_template=False, stored=False)
- title = indexes.CharField(model_attr='title')
- description = indexes.CharField(model_attr='description')
- tag = indexes.CharField(model_attr='state')
- url = indexes.CharField(model_attr='url', indexed=False)
- icon_name = indexes.CharField()
- type = indexes.CharField(model_attr='type')
-
- modified_by = indexes.CharField(model_attr='modified_by', null=True)
- modified_by_url = indexes.CharField(model_attr='modified_by_url',
- null=True)
- modified = indexes.DateTimeField(model_attr='created_at', null=True)
-
- def get_model(self):
- return GitlabIssue
-
- def prepare_icon_name(self, obj):
- return u'align-right'
-
- def prepare_type(self, obj):
- return u'merge_request'
-
-
-class GitlabCommentIndex(indexes.SearchIndex, indexes.Indexable):
-
- text = indexes.CharField(document=True, use_template=False, stored=False)
- title = indexes.CharField(model_attr='title')
- description = indexes.CharField(model_attr='description')
- tag = indexes.CharField()
- url = indexes.CharField(model_attr='url', indexed=False)
- icon_name = indexes.CharField()
- type = indexes.CharField(model_attr='type')
-
- modified_by = indexes.CharField(model_attr='modified_by', null=True)
- modified_by_url = indexes.CharField(model_attr='modified_by_url',
- null=True)
- modified = indexes.DateTimeField(model_attr='created_at', null=True)
-
- def get_model(self):
- return GitlabComment
-
- def prepare_icon_name(self, obj):
- return u'align-right'
-
- def prepare_tag(self, obj):
- return obj.tag
diff --git a/colab/plugins/gitlab/tasks.py b/colab/plugins/gitlab/tasks.py
deleted file mode 100644
index 9720002..0000000
--- a/colab/plugins/gitlab/tasks.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-from colab.celery import app
-
-
-@app.task(bind=True)
-def handling_method(self, **kwargs):
- f = open('/vagrant/test_plugin', 'wb')
- f.write(str(kwargs))
- f.close()
- return 5
diff --git a/colab/plugins/gitlab/templates/proxy/gitlab.html b/colab/plugins/gitlab/templates/proxy/gitlab.html
deleted file mode 100644
index 1e48b8a..0000000
--- a/colab/plugins/gitlab/templates/proxy/gitlab.html
+++ /dev/null
@@ -1,56 +0,0 @@
-{% extends 'base.html' %}
-{% load static from staticfiles %}
-
-{% block head_css %}
-
-{% endblock %}
-
-{% block head_js %}
-
-
-
-
-{% endblock %}
diff --git a/colab/plugins/gitlab/tests/__init__.py b/colab/plugins/gitlab/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/colab/plugins/gitlab/tests/__init__.py
+++ /dev/null
diff --git a/colab/plugins/gitlab/tests/data.py b/colab/plugins/gitlab/tests/data.py
deleted file mode 100644
index a2b47a4..0000000
--- a/colab/plugins/gitlab/tests/data.py
+++ /dev/null
@@ -1,98 +0,0 @@
-colab_apps = {'gitlab':
- {'menu_title': None,
- 'private_token': 'token',
- 'upstream': 'localhost',
- 'urls':
- {'include': 'colab.plugins.gitlab.urls',
- 'namespace': 'gitlab',
- 'prefix': 'gitlab/'}}}
-
-projects_json = [{"id": 32,
- "description": "Test Gitlab",
- "default_branch": "master",
- "public": True,
- "archived": False,
- "visibility_level": 20,
- "ssh_url_to_repo": "git@localhost/gitlabhq.git",
- "http_url_to_repo": "localhost/gitlabhq.git",
- "web_url": "localhost/gitlabhq",
- "name": "Gitlab",
- "name_with_namespace": "Test / Gitlab",
- "path": "gitlabhq"}]
-
-groups_json = [{"id": 23,
- "name": "Group 1",
- "path": "group-1",
- "owner_id": None},
- {"id": 27,
- "name": "Group 2",
- "path": "group-2",
- "owner_id": None}]
-
-merge_json = [{"id": 7,
- "iid": 1,
- "project_id": 14,
- "title": "Merge Title",
- "description": "description",
- "state": "merged",
- "created_at": "2014-10-24T12:05:55.659Z",
- "updated_at": "2014-10-24T12:06:15.572Z",
- "target_branch": "master",
- "source_branch": "settings_fix",
- "upvotes": 0,
- "downvotes": 0,
- "author": {"name": "user",
- "username": "user",
- "id": 8,
- "state": "active",
- "avatar_url": "localhost"},
- "assignee": {"name": "user",
- "username": "user",
- "id": 8,
- "state": "active",
- "avatar_url": "localhost"},
- "source_project_id": 14,
- "target_project_id": 14,
- "labels": [],
- "milestone": None}]
-
-issues_json = [{"id": 8,
- "iid": 1,
- "project_id": 32,
- "title": "title",
- "description": "description",
- "state": "opened",
- "created_at": "2014-10-11T16:25:37.548Z",
- "updated_at": "2014-10-11T16:25:37.548Z",
- "labels": [],
- "milestone": None,
- "assignee": {"name": "name",
- "username": "username",
- "id": 2,
- "state": "active",
- "avatar_url": "avatar_url"},
- "author": {"name": "name",
- "username": "user",
- "id": 2,
- "state": "active",
- "avatar_url": "avatar_url"}}]
-
-comment_mr_json = [{"id": 11,
- "body": "message body",
- "attachment": None,
- "author": {"name": "user",
- "username": "user",
- "id": 8,
- "state": "active",
- "avatar_url": "avatar_url"},
- "created_at": "2014-10-25T14:43:54.863Z"}]
-
-comment_issue_json = [{"id": 447,
- "body": "message body",
- "attachment": None,
- "author": {"name": "user",
- "username": "user",
- "state": "active",
- "id": 8,
- "avatar_url": "avatar_url"},
- "created_at": "2015-03-16T17:34:07.715Z"}]
diff --git a/colab/plugins/gitlab/tests/test_data_importer.py b/colab/plugins/gitlab/tests/test_data_importer.py
deleted file mode 100644
index 5826397..0000000
--- a/colab/plugins/gitlab/tests/test_data_importer.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from django.test import TestCase
-from django.test.utils import override_settings
-from ..data_importer import GitlabDataImporter
-from ..models import GitlabProject, GitlabIssue
-from mock import patch
-import data
-from dateutil.parser import parse
-
-
-class GitlabDataImporterTest(TestCase):
-
- fixtures = ["gitlab_associations"]
-
- @override_settings(COLAB_APPS=data.colab_apps)
- def setUp(self):
- self.api = GitlabDataImporter()
-
- def test_resquest_url(self):
- url = self.api.get_request_url('/gitlab/test/')
- expected = 'localhost/gitlab/test/?private_token=token'
- self.assertEqual(url, expected)
-
- def test_resquest_url_with_params(self):
- url = self.api.get_request_url('/gitlab/test/', param='param')
- expected = 'localhost/gitlab/test/?private_token=token¶m=param'
- self.assertEqual(url, expected)
-
- @patch.object(GitlabDataImporter, 'get_json_data')
- def test_fetch_projects(self, mock_json):
- mock_json.side_effect = [data.projects_json, []]
-
- projects = self.api.fetch_projects()
- self.assertEqual(len(projects), 1)
-
- self.assertEqual(projects[0].description, "Test Gitlab")
- self.assertEqual(projects[0].public, True)
-
- @patch.object(GitlabDataImporter, 'get_json_data')
- def test_fetch_groups(self, mock_json):
- mock_json.side_effect = [data.groups_json, []]
-
- groups = self.api.fetch_groups()
- self.assertEqual(len(groups), 2)
- self.assertEqual(groups[0].name, "Group 1")
- self.assertEqual(groups[1].name, "Group 2")
-
- self.assertEqual(groups[0].path, "group-1")
- self.assertEqual(groups[1].path, "group-2")
-
- @patch.object(GitlabDataImporter, 'get_json_data')
- def test_fetch_merge(self, mock_json):
- mock_json.side_effect = [data.merge_json, []]
-
- merges = self.api.fetch_merge_request([GitlabProject()])
- self.assertEqual(len(merges), 1)
- self.assertEqual(merges[0].title, "Merge Title")
- self.assertEqual(merges[0].description, "description")
- self.assertEqual(merges[0].get_author().username, "user")
-
- @patch.object(GitlabDataImporter, 'get_json_data')
- def test_fetch_issues(self, mock_json):
- mock_json.side_effect = [data.issues_json, []]
-
- issues = self.api.fetch_issue([GitlabProject()])
- assert mock_json.called
- self.assertEqual(len(issues), 1)
- self.assertEqual(issues[0].title, "title")
- self.assertEqual(issues[0].description, "description")
- self.assertEqual(issues[0].state, "opened")
-
- @patch.object(GitlabDataImporter, 'get_json_data')
- def test_fetch_comments_mr(self, mock_json):
- mock_json.side_effect = [data.comment_mr_json, []]
-
- comments_mr = self.api.fetch_comments_mr()
- self.assertEqual(len(comments_mr), 1)
- self.assertEqual(comments_mr[0].body, "message body")
- self.assertEqual(comments_mr[0].user.username, "user")
-
- @patch.object(GitlabDataImporter, 'get_json_data')
- def test_fetch_comments_issues(self, mock_json):
- mock_json.side_effect = [data.comment_issue_json, []]
-
- comments_issue = self.api.fetch_comments_issues()
- self.assertEqual(len(comments_issue), 1)
- self.assertEqual(comments_issue[0].body, "message body")
- self.assertEqual(comments_issue[0].user.username, "user")
-
- def test_fill_object_data(self):
- issue = GitlabIssue()
-
- self.api.fill_object_data(data.issues_json[0], issue)
- self.assertIsNotNone(issue.user)
- self.assertEqual(issue.user.username, "user")
- self.assertEqual(issue.created_at, parse("2014-10-11T16:25:37.548Z"))
- self.assertEqual(issue.project_id, 32)
- self.assertEqual(issue.title, "title")
diff --git a/colab/plugins/gitlab/tests/test_gitlab.py b/colab/plugins/gitlab/tests/test_gitlab.py
deleted file mode 100644
index 40ebf74..0000000
--- a/colab/plugins/gitlab/tests/test_gitlab.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test User class.
-Objective: Test parameters, and behavior.
-"""
-from django.test import TestCase, Client
-from colab.plugins.gitlab.models import (GitlabProject, GitlabGroup,
- GitlabIssue, GitlabComment,
- GitlabMergeRequest)
-
-
-class GitlabTest(TestCase):
-
- fixtures = ['test_gitlab_data']
-
- def setUp(self):
- self.client = Client()
-
- super(GitlabTest, self).setUp()
-
- def tearDown(self):
- pass
-
- def test_data_integrity(self):
- self.assertEqual(GitlabGroup.objects.all().count(), 1)
- self.assertEqual(GitlabProject.objects.all().count(), 2)
- self.assertEqual(GitlabMergeRequest.objects.all().count(), 2)
- self.assertEqual(GitlabIssue.objects.all().count(), 2)
- self.assertEqual(GitlabComment.objects.all().count(), 2)
-
- def test_project_url(self):
- self.assertEqual(GitlabProject.objects.get(id=1).url,
- '/gitlab/softwarepublico/colab')
-
- def test_project_group(self):
- project = GitlabProject.objects.get(id=1)
- self.assertEqual(project.name, 'colab')
- self.assertEqual(project.namespace, 'softwarepublico')
-
- def test_namespace_projects(self):
- group = GitlabGroup.objects.get(id=1)
- self.assertEqual(len(group.projects), 2)
- self.assertEqual(group.projects[0].name, 'colab')
- self.assertEqual(group.projects[1].name, 'colabinc')
-
- def test_merge_request_url(self):
- self.assertEqual(GitlabMergeRequest.objects.get(id=1).url,
- '/gitlab/softwarepublico/colab/merge_requests/1')
- self.assertEqual(GitlabMergeRequest.objects.get(id=2).url,
- '/gitlab/softwarepublico/colabinc/merge_requests/1')
-
- def test_issue_url(self):
- self.assertEqual(GitlabIssue.objects.get(id=1).url,
- '/gitlab/softwarepublico/colab/issues/1')
- self.assertEqual(GitlabIssue.objects.get(id=2).url,
- '/gitlab/softwarepublico/colabinc/issues/1')
-
- def test_comment_on_mr_url(self):
- url = '/gitlab/softwarepublico/colab/merge_requests/1#notes_1'
- self.assertEqual(GitlabComment.objects.get(id=1).url, url)
-
- def test_comment_on_issue_url(self):
- self.assertEqual(GitlabComment.objects.get(id=2).url,
- '/gitlab/softwarepublico/colab/issues/1#notes_2')
diff --git a/colab/plugins/gitlab/urls.py b/colab/plugins/gitlab/urls.py
deleted file mode 100644
index fa2ec6b..0000000
--- a/colab/plugins/gitlab/urls.py
+++ /dev/null
@@ -1,9 +0,0 @@
-
-from django.conf.urls import patterns, url
-
-from .views import GitlabProxyView
-
-urlpatterns = patterns('',
- # Gitlab URLs
- url(r'^(?P.*)$', GitlabProxyView.as_view(), name='gitlab'),
-)
diff --git a/colab/plugins/gitlab/views.py b/colab/plugins/gitlab/views.py
deleted file mode 100644
index 0839a7f..0000000
--- a/colab/plugins/gitlab/views.py
+++ /dev/null
@@ -1,7 +0,0 @@
-
-from colab.plugins.views import ColabProxyView
-
-
-class GitlabProxyView(ColabProxyView):
- app_label = 'gitlab'
- diazo_theme_template = 'proxy/gitlab.html'
diff --git a/colab/urls.py b/colab/urls.py
index cf8f5b3..4e05d7c 100644
--- a/colab/urls.py
+++ b/colab/urls.py
@@ -21,7 +21,6 @@ urlpatterns = patterns('',
url(r'^colab/admin/', include(admin.site.urls)),
url(r'^archives/', include('colab.super_archives.urls')),
- url(r'^gitlab/', include('colab.plugins.gitlab.urls')),
url(r'^mezuro/', include('colab.plugins.mezuro.urls')),
url(r'^social/', include('colab.plugins.noosfero.urls')),
diff --git a/setup.py b/setup.py
index 2e55245..cef6a4d 100644
--- a/setup.py
+++ b/setup.py
@@ -24,10 +24,6 @@ REQUIREMENTS = [
'django-taggit>=0.12.1',
'html2text>=3.200.3',
'chardet>=2.3.0',
-
- # Deps for gitlab plugin
- 'python-dateutil>=1.5',
- 'requests',
]
TEST_REQUIREMENTS = [
diff --git a/tests/plugins.d/gitlab.py b/tests/plugins.d/gitlab.py
deleted file mode 100644
index b0f9cb9..0000000
--- a/tests/plugins.d/gitlab.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from django.utils.translation import ugettext_lazy as _
-
-name = 'colab.plugins.gitlab'
-verbose_name = 'Gitlab Proxy'
-
-upstream = 'localhost'
-#middlewares = []
-
-menu = {
-'title': _('Code'),
-'links': (
- (_('Public Projects'), 'public/projects'),
-),
-'auth_links': (
- (_('Profile'), 'profile'),
- (_('New Project'), 'projects/new'),
- (_('Projects'), 'dashboard/projects'),
- (_('Groups'), 'profile/groups'),
- (_('Issues'), 'dashboard/issues'),
- (_('Merge Requests'), 'dashboard/merge_requests'),
-
-),
-}
-
-
-# dpaste:
-# dependencies:
-# - 'mptt'
-# urls:
-# include: 'dpaste.urls.dpaste'
-# prefix: '^paste/'
-# namespace: 'dpaste'
-# menu:
-# title: 'Dpaste'
-# links:
-# Public Projects: '/paste'
-# auth_links:
-# Profile: '/projects'
-# New Project: '/projects/new'
--
libgit2 0.21.2