Commit 7f0d43e68bda03c59f651e5e3c6e9c0bf2ea1d62
1 parent
9a33ed75
Exists in
master
and in
24 other branches
Remove gitlab plugin from colab
Now available on: https://github.com/colab/colab-gitlab-plugin Signed-off-by: Sergio Oliveira <sergio@tracy.com.br> Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
Showing
23 changed files
with
0 additions
and
1327 deletions
Show diff stats
colab/management/commands/initconfig.py
@@ -73,45 +73,6 @@ LOGGING = {{ | @@ -73,45 +73,6 @@ LOGGING = {{ | ||
73 | }}, | 73 | }}, |
74 | }}, | 74 | }}, |
75 | }} | 75 | }} |
76 | - | ||
77 | - | ||
78 | -## Gitlab plugin - Put this in plugins.d/gitlab.py to actiate ## | ||
79 | -# from django.utils.translation import ugettext_lazy as _ | ||
80 | -# from colab.plugins.utils.menu import colab_url_factory | ||
81 | -# | ||
82 | -# name = 'colab.plugins.gitlab' | ||
83 | -# verbose_name = 'Gitlab Plugin' | ||
84 | -# | ||
85 | -# upstream = 'localhost' | ||
86 | -# #middlewares = [] | ||
87 | -# | ||
88 | -# urls = {{ | ||
89 | -# 'include': 'colab.plugins.gitlab.urls', | ||
90 | -# 'namespace': 'gitlab', | ||
91 | -# 'prefix': 'gitlab', | ||
92 | -# }} | ||
93 | -# | ||
94 | -# menu_title = _('Code') | ||
95 | -# | ||
96 | -# url = colab_url_factory('gitlab') | ||
97 | -# | ||
98 | -# menu_urls = ( | ||
99 | -# url(display=_('Public Projects'), viewname='gitlab', | ||
100 | -# kwargs={{'path': '/public/projects'}}, auth=False), | ||
101 | -# url(display=_('Profile'), viewname='gitlab', | ||
102 | -# kwargs={{'path': '/profile'}}, auth=True), | ||
103 | -# url(display=_('New Project'), viewname='gitlab', | ||
104 | -# kwargs={{'path': '/projects/new'}}, auth=True), | ||
105 | -# url(display=_('Projects'), viewname='gitlab', | ||
106 | -# kwargs={{'path': '/dashboard/projects'}}, auth=True), | ||
107 | -# url(display=_('Groups'), viewname='gitlab', | ||
108 | -# kwargs={{'path': '/profile/groups'}}, auth=True), | ||
109 | -# url(display=_('Issues'), viewname='gitlab', | ||
110 | -# kwargs={{'path': '/dashboard/issues'}}, auth=True), | ||
111 | -# url(display=_('Merge Requests'), viewname='gitlab', | ||
112 | -# kwargs={{'path': '/merge_requests'}}, auth=True), | ||
113 | -# | ||
114 | -# ) | ||
115 | """ | 76 | """ |
116 | 77 | ||
117 | 78 |
colab/plugins/gitlab/__init__.py
colab/plugins/gitlab/apps.py
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | - | ||
2 | -from ..utils.apps import ColabPluginAppConfig | ||
3 | -from colab.plugins.gitlab.tasks import handling_method | ||
4 | -from colab.signals.signals import register_signal, connect_signal | ||
5 | - | ||
6 | - | ||
7 | -class GitlabPluginAppConfig(ColabPluginAppConfig): | ||
8 | - name = 'colab.plugins.gitlab' | ||
9 | - verbose_name = 'Gitlab Plugin' | ||
10 | - short_name = 'gitlab' | ||
11 | - | ||
12 | - signals_list = ['gitlab_create_project'] | ||
13 | - | ||
14 | - def register_signal(self): | ||
15 | - register_signal(self.short_name, self.signals_list) | ||
16 | - | ||
17 | - def connect_signal(self): | ||
18 | - connect_signal(self.signals_list[0], self.short_name, handling_method) |
colab/plugins/gitlab/data_importer.py
@@ -1,188 +0,0 @@ | @@ -1,188 +0,0 @@ | ||
1 | -import json | ||
2 | -import urllib | ||
3 | -import urllib2 | ||
4 | -import logging | ||
5 | - | ||
6 | -from dateutil.parser import parse | ||
7 | - | ||
8 | -from django.db.models.fields import DateTimeField | ||
9 | -from colab.plugins.data import PluginDataImporter | ||
10 | - | ||
11 | -from .models import (GitlabProject, GitlabMergeRequest, | ||
12 | - GitlabComment, GitlabIssue, GitlabGroup) | ||
13 | - | ||
14 | - | ||
15 | -LOGGER = logging.getLogger('colab.plugin.gitlab') | ||
16 | - | ||
17 | - | ||
18 | -class GitlabDataImporter(PluginDataImporter): | ||
19 | - app_label = 'gitlab' | ||
20 | - | ||
21 | - def get_request_url(self, path, **kwargs): | ||
22 | - upstream = self.config.get('upstream') | ||
23 | - kwargs['private_token'] = self.config.get('private_token') | ||
24 | - params = urllib.urlencode(kwargs) | ||
25 | - | ||
26 | - if upstream[-1] == '/': | ||
27 | - upstream = upstream[:-1] | ||
28 | - | ||
29 | - return u'{}{}?{}'.format(upstream, path, params) | ||
30 | - | ||
31 | - def get_json_data(self, api_url, page, pages=1000): | ||
32 | - url = self.get_request_url(api_url, per_page=pages, | ||
33 | - page=page) | ||
34 | - | ||
35 | - try: | ||
36 | - data = urllib2.urlopen(url, timeout=10) | ||
37 | - json_data = json.load(data) | ||
38 | - except urllib2.URLError: | ||
39 | - LOGGER.exception("Connection timeout: " + url) | ||
40 | - json_data = [] | ||
41 | - | ||
42 | - return json_data | ||
43 | - | ||
44 | - def fill_object_data(self, element, _object): | ||
45 | - for field in _object._meta.fields: | ||
46 | - try: | ||
47 | - if field.name == "user": | ||
48 | - _object.update_user( | ||
49 | - element["author"]["username"]) | ||
50 | - continue | ||
51 | - if field.name == "project": | ||
52 | - _object.project_id = element["project_id"] | ||
53 | - continue | ||
54 | - | ||
55 | - if isinstance(field, DateTimeField): | ||
56 | - value = parse(element[field.name]) | ||
57 | - else: | ||
58 | - value = element[field.name] | ||
59 | - | ||
60 | - setattr(_object, field.name, value) | ||
61 | - except KeyError: | ||
62 | - continue | ||
63 | - | ||
64 | - return _object | ||
65 | - | ||
66 | - def fetch(self, url, gitlab_class): | ||
67 | - page = 1 | ||
68 | - obj_list = [] | ||
69 | - | ||
70 | - while True: | ||
71 | - json_data = self.get_json_data(url, page) | ||
72 | - page = page + 1 | ||
73 | - | ||
74 | - if not len(json_data): | ||
75 | - break | ||
76 | - | ||
77 | - for element in json_data: | ||
78 | - obj = gitlab_class() | ||
79 | - self.fill_object_data(element, obj) | ||
80 | - obj_list.append(obj) | ||
81 | - | ||
82 | - return obj_list | ||
83 | - | ||
84 | - def fetch_comments(self, url, parent_class, issue_comment): | ||
85 | - all_comments = [] | ||
86 | - all_parent_objects = parent_class.objects.all() | ||
87 | - | ||
88 | - for parent_obj in all_parent_objects: | ||
89 | - page = 1 | ||
90 | - while True: | ||
91 | - formated_url = url.format(parent_obj.project_id, parent_obj.id) | ||
92 | - json_data = self.get_json_data(formated_url, page) | ||
93 | - page = page + 1 | ||
94 | - | ||
95 | - if len(json_data) == 0: | ||
96 | - break | ||
97 | - | ||
98 | - for element in json_data: | ||
99 | - single_comment = GitlabComment() | ||
100 | - self.fill_object_data(element, single_comment) | ||
101 | - single_comment.project = parent_obj.project | ||
102 | - single_comment.issue_comment = issue_comment | ||
103 | - single_comment.parent_id = parent_obj.id | ||
104 | - all_comments.append(single_comment) | ||
105 | - | ||
106 | - return all_comments | ||
107 | - | ||
108 | - def fetch_projects(self): | ||
109 | - return self.fetch('/api/v3/projects/all', GitlabProject) | ||
110 | - | ||
111 | - def fetch_groups(self): | ||
112 | - return self.fetch('/api/v3/groups', GitlabGroup) | ||
113 | - | ||
114 | - def fetch_merge_request(self, projects): | ||
115 | - merge_requests = [] | ||
116 | - for project in projects: | ||
117 | - url = '/api/v3/projects/{}/merge_requests'.format(project.id) | ||
118 | - merge_requests.extend(self.fetch(url, GitlabMergeRequest)) | ||
119 | - return merge_requests | ||
120 | - | ||
121 | - def fetch_issue(self, projects): | ||
122 | - issues = [] | ||
123 | - for project in projects: | ||
124 | - url = '/api/v3/projects/{}/issues'.format(project.id) | ||
125 | - issues.extend(self.fetch(url, GitlabIssue)) | ||
126 | - return issues | ||
127 | - | ||
128 | - def fetch_all_comments(self): | ||
129 | - all_comments = [] | ||
130 | - all_comments.extend(self.fetch_comments_mr()) | ||
131 | - all_comments.extend(self.fetch_comments_issues()) | ||
132 | - | ||
133 | - return all_comments | ||
134 | - | ||
135 | - def fetch_comments_mr(self): | ||
136 | - url = '/api/v3/projects/{}/merge_requests/{}/notes' | ||
137 | - return self.fetch_comments(url, GitlabMergeRequest, False) | ||
138 | - | ||
139 | - def fetch_comments_issues(self): | ||
140 | - url = '/api/v3/projects/{}/issues/{}/notes' | ||
141 | - return self.fetch_comments(url, GitlabIssue, True) | ||
142 | - | ||
143 | - | ||
144 | -class GitlabProjectImporter(GitlabDataImporter): | ||
145 | - | ||
146 | - def fetch_data(self): | ||
147 | - LOGGER.info("Importing Projects") | ||
148 | - projects = self.fetch_projects() | ||
149 | - for datum in projects: | ||
150 | - datum.save() | ||
151 | - | ||
152 | - | ||
153 | -class GitlabGroupImporter(GitlabDataImporter): | ||
154 | - | ||
155 | - def fetch_data(self): | ||
156 | - LOGGER.info("Importing Group") | ||
157 | - groups_list = self.fetch_groups() | ||
158 | - for datum in groups_list: | ||
159 | - datum.save() | ||
160 | - | ||
161 | - | ||
162 | -class GitlabMergeRequestImporter(GitlabDataImporter): | ||
163 | - | ||
164 | - def fetch_data(self): | ||
165 | - LOGGER.info("Importing Merge Requests") | ||
166 | - projects = GitlabProject.objects.all() | ||
167 | - merge_request_list = self.fetch_merge_request(projects) | ||
168 | - for datum in merge_request_list: | ||
169 | - datum.save() | ||
170 | - | ||
171 | - | ||
172 | -class GitlabIssueImporter(GitlabDataImporter): | ||
173 | - | ||
174 | - def fetch_data(self): | ||
175 | - LOGGER.info("Importing Issues") | ||
176 | - projects = GitlabProject.objects.all() | ||
177 | - issue_list = self.fetch_issue(projects) | ||
178 | - for datum in issue_list: | ||
179 | - datum.save() | ||
180 | - | ||
181 | - | ||
182 | -class GitlabCommentImporter(GitlabDataImporter): | ||
183 | - | ||
184 | - def fetch_data(self): | ||
185 | - LOGGER.info("Importing Comments") | ||
186 | - comments_list = self.fetch_all_comments() | ||
187 | - for datum in comments_list: | ||
188 | - datum.save() |
colab/plugins/gitlab/diazo.xml
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -<rules | ||
2 | - xmlns="http://namespaces.plone.org/diazo" | ||
3 | - xmlns:css="http://namespaces.plone.org/diazo/css" | ||
4 | - xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
5 | - | ||
6 | - <before theme-children="/html/head" content-children="/html/head" /> | ||
7 | - <before css:theme-children="#main-content" css:content-children="body" /> | ||
8 | - | ||
9 | - <merge attributes="class" css:theme="body" css:content="body" /> | ||
10 | - | ||
11 | - <!-- Add gitlab properties --> | ||
12 | - <merge attributes="data-page" css:theme="body" css:content="body" /> | ||
13 | - <merge attributes="data-project-id" css:theme="body" css:content="body" /> | ||
14 | - | ||
15 | - <drop css:content="#top-panel" /> | ||
16 | - <drop css:content=".navbar-gitlab" /> | ||
17 | - <drop css:content=".git-clone-holder .btn:contains('HTTPS')" /> | ||
18 | -</rules> |
colab/plugins/gitlab/fixtures/__init__.py
colab/plugins/gitlab/fixtures/gitlab_associations.json
@@ -1,100 +0,0 @@ | @@ -1,100 +0,0 @@ | ||
1 | -[ | ||
2 | -{ | ||
3 | - "fields": { | ||
4 | - "last_name": "Administrator", | ||
5 | - "webpage": "", | ||
6 | - "twitter": "", | ||
7 | - "is_staff": true, | ||
8 | - "user_permissions": [], | ||
9 | - "date_joined": "2015-01-28T12:34:58.770Z", | ||
10 | - "google_talk": "", | ||
11 | - "first_name": "Admin", | ||
12 | - "is_superuser": true, | ||
13 | - "last_login": "2015-08-24T14:33:28.802Z", | ||
14 | - "verification_hash": null, | ||
15 | - "role": "", | ||
16 | - "email": "admin@mail.com", | ||
17 | - "username": "admin", | ||
18 | - "bio": "", | ||
19 | - "needs_update": true, | ||
20 | - "is_active": true, | ||
21 | - "facebook": "", | ||
22 | - "groups": [], | ||
23 | - "password": "pbkdf2_sha256$15000$sWnvfYpB8ec4$7dEFg6vSSGPnpEmfRelJ12zkiwacGx9aXx8/8ZFWBSI=", | ||
24 | - "institution": "", | ||
25 | - "github": "", | ||
26 | - "modified": "2015-01-28T12:45:27.375Z" | ||
27 | - }, | ||
28 | - "model": "accounts.user", | ||
29 | - "pk": 1 | ||
30 | -}, | ||
31 | -{ | ||
32 | - "fields": { | ||
33 | - "last_name": "user", | ||
34 | - "webpage": null, | ||
35 | - "twitter": null, | ||
36 | - "is_staff": false, | ||
37 | - "user_permissions": [], | ||
38 | - "date_joined": "2015-08-24T14:33:55.827Z", | ||
39 | - "google_talk": null, | ||
40 | - "first_name": "user", | ||
41 | - "is_superuser": false, | ||
42 | - "last_login": "2015-08-24T14:33:55.827Z", | ||
43 | - "verification_hash": null, | ||
44 | - "role": null, | ||
45 | - "email": "user@teste.com", | ||
46 | - "username": "user", | ||
47 | - "bio": null, | ||
48 | - "needs_update": true, | ||
49 | - "is_active": true, | ||
50 | - "facebook": null, | ||
51 | - "groups": [], | ||
52 | - "password": "pbkdf2_sha256$15000$9ew6EvFvAIhI$147annuMjzt7em5IRh+3k7wcl7rZ0xjBPSmbUZDdxFo=", | ||
53 | - "institution": null, | ||
54 | - "github": null, | ||
55 | - "modified": "2015-08-24T14:33:55.893Z" | ||
56 | - }, | ||
57 | - "model": "accounts.user", | ||
58 | - "pk": 2 | ||
59 | -}, | ||
60 | -{ | ||
61 | - "fields": { | ||
62 | - "last_activity_at": "2015-06-08T19:28:27.148Z", | ||
63 | - "description": "Colab source code", | ||
64 | - "name_with_namespace": "Software Publico / Colab", | ||
65 | - "created_at": "2014-09-26T14:58:52.491Z", | ||
66 | - "path_with_namespace": "softwarepublico/colab", | ||
67 | - "public": true, | ||
68 | - "name": "Colab" | ||
69 | - }, | ||
70 | - "model": "gitlab.gitlabproject", | ||
71 | - "pk": 14 | ||
72 | -}, | ||
73 | -{ | ||
74 | - "fields": { | ||
75 | - "target_branch": "master", | ||
76 | - "description": "", | ||
77 | - "source_branch": "settings_fix", | ||
78 | - "created_at": "2014-10-24T12:05:55.659Z", | ||
79 | - "title": "Settings fix", | ||
80 | - "project": 14, | ||
81 | - "iid": 1, | ||
82 | - "state": "merged", | ||
83 | - "user": null | ||
84 | - }, | ||
85 | - "model": "gitlab.gitlabmergerequest", | ||
86 | - "pk": 7 | ||
87 | -}, | ||
88 | -{ | ||
89 | - "fields": { | ||
90 | - "description": "Remove the main SPB logo from the homepage", | ||
91 | - "title": "Remove the SPB central logo", | ||
92 | - "created_at": "2014-10-07T17:40:27.625Z", | ||
93 | - "project": 14, | ||
94 | - "state": "closed", | ||
95 | - "user": null | ||
96 | - }, | ||
97 | - "model": "gitlab.gitlabissue", | ||
98 | - "pk": 2 | ||
99 | -} | ||
100 | -] | ||
101 | \ No newline at end of file | 0 | \ No newline at end of file |
colab/plugins/gitlab/fixtures/test_gitlab_data.json
@@ -1,146 +0,0 @@ | @@ -1,146 +0,0 @@ | ||
1 | -[ | ||
2 | -{ | ||
3 | - "fields": { | ||
4 | - "last_name": "COLAB", | ||
5 | - "webpage": null, | ||
6 | - "twitter": "usertestcolab", | ||
7 | - "is_staff": false, | ||
8 | - "user_permissions": [], | ||
9 | - "date_joined": "2015-08-28T18:00:59.753Z", | ||
10 | - "google_talk": null, | ||
11 | - "first_name": "USERtestCoLaB", | ||
12 | - "is_superuser": false, | ||
13 | - "last_login": "2015-08-28T18:00:59.753Z", | ||
14 | - "verification_hash": null, | ||
15 | - "role": null, | ||
16 | - "email": "usertest@colab.com.br", | ||
17 | - "username": "usertestcolab", | ||
18 | - "bio": null, | ||
19 | - "needs_update": true, | ||
20 | - "is_active": true, | ||
21 | - "facebook": "usertestcolab", | ||
22 | - "groups": [], | ||
23 | - "password": "pbkdf2_sha256$15000$unxhDDCB1vsw$Esdx3tQ2ayPW08/SImQzbBeRiK8Hoa6fBZhw3dMQga8=", | ||
24 | - "institution": null, | ||
25 | - "github": null, | ||
26 | - "modified": "2015-08-28T18:00:59.996Z" | ||
27 | - }, | ||
28 | - "model": "accounts.user", | ||
29 | - "pk": 1 | ||
30 | -}, | ||
31 | -{ | ||
32 | - "fields": { | ||
33 | - "last_activity_at": "2015-08-28T18:01:28.469Z", | ||
34 | - "description": "", | ||
35 | - "name_with_namespace": "Software Public / Colab", | ||
36 | - "created_at": "2015-08-28T18:01:28.467Z", | ||
37 | - "path_with_namespace": "softwarepublico/colab", | ||
38 | - "public": true, | ||
39 | - "name": "colab" | ||
40 | - }, | ||
41 | - "model": "gitlab.gitlabproject", | ||
42 | - "pk": 1 | ||
43 | -}, | ||
44 | -{ | ||
45 | - "fields": { | ||
46 | - "last_activity_at": "2015-08-28T18:01:28.491Z", | ||
47 | - "description": "", | ||
48 | - "name_with_namespace": "Software Public / ColabInc", | ||
49 | - "created_at": "2015-08-28T18:01:28.489Z", | ||
50 | - "path_with_namespace": "softwarepublico/colabinc", | ||
51 | - "public": true, | ||
52 | - "name": "colabinc" | ||
53 | - }, | ||
54 | - "model": "gitlab.gitlabproject", | ||
55 | - "pk": 2 | ||
56 | -}, | ||
57 | -{ | ||
58 | - "fields": { | ||
59 | - "path": "softwarepublico", | ||
60 | - "name": "Software Public", | ||
61 | - "owner_id": 1 | ||
62 | - }, | ||
63 | - "model": "gitlab.gitlabgroup", | ||
64 | - "pk": 1 | ||
65 | -}, | ||
66 | -{ | ||
67 | - "fields": { | ||
68 | - "target_branch": "", | ||
69 | - "description": "Merge request for plugin support", | ||
70 | - "source_branch": "", | ||
71 | - "created_at": "2015-08-28T18:01:28.512Z", | ||
72 | - "title": "Include plugin support", | ||
73 | - "project": 1, | ||
74 | - "iid": 1, | ||
75 | - "state": "Closed", | ||
76 | - "user": 1 | ||
77 | - }, | ||
78 | - "model": "gitlab.gitlabmergerequest", | ||
79 | - "pk": 1 | ||
80 | -}, | ||
81 | -{ | ||
82 | - "fields": { | ||
83 | - "target_branch": "", | ||
84 | - "description": "Merge request for test support", | ||
85 | - "source_branch": "", | ||
86 | - "created_at": "2015-08-28T18:01:28.561Z", | ||
87 | - "title": "Include test support", | ||
88 | - "project": 2, | ||
89 | - "iid": 1, | ||
90 | - "state": "Closed", | ||
91 | - "user": 1 | ||
92 | - }, | ||
93 | - "model": "gitlab.gitlabmergerequest", | ||
94 | - "pk": 2 | ||
95 | -}, | ||
96 | -{ | ||
97 | - "fields": { | ||
98 | - "description": "Issue reported to colab", | ||
99 | - "title": "Issue for colab", | ||
100 | - "created_at": "2015-08-28T18:01:28.590Z", | ||
101 | - "project": 1, | ||
102 | - "iid": 1, | ||
103 | - "state": "Open", | ||
104 | - "user": 1 | ||
105 | - }, | ||
106 | - "model": "gitlab.gitlabissue", | ||
107 | - "pk": 1 | ||
108 | -}, | ||
109 | -{ | ||
110 | - "fields": { | ||
111 | - "description": "Issue reported to colab", | ||
112 | - "title": "Issue for colab", | ||
113 | - "created_at": "2015-08-28T18:01:28.628Z", | ||
114 | - "project": 2, | ||
115 | - "iid": 1, | ||
116 | - "state": "Open", | ||
117 | - "user": 1 | ||
118 | - }, | ||
119 | - "model": "gitlab.gitlabissue", | ||
120 | - "pk": 2 | ||
121 | -}, | ||
122 | -{ | ||
123 | - "fields": { | ||
124 | - "body": "Comment to merge request", | ||
125 | - "created_at": "2015-08-28T18:01:28.663Z", | ||
126 | - "issue_comment": false, | ||
127 | - "project": 1, | ||
128 | - "parent_id": 1, | ||
129 | - "user": 1 | ||
130 | - }, | ||
131 | - "model": "gitlab.gitlabcomment", | ||
132 | - "pk": 1 | ||
133 | -}, | ||
134 | -{ | ||
135 | - "fields": { | ||
136 | - "body": "Comment to issue", | ||
137 | - "created_at": "2015-08-28T18:01:28.693Z", | ||
138 | - "issue_comment": true, | ||
139 | - "project": 1, | ||
140 | - "parent_id": 1, | ||
141 | - "user": 1 | ||
142 | - }, | ||
143 | - "model": "gitlab.gitlabcomment", | ||
144 | - "pk": 2 | ||
145 | -} | ||
146 | -] |
colab/plugins/gitlab/migrations/0001_initial.py
@@ -1,134 +0,0 @@ | @@ -1,134 +0,0 @@ | ||
1 | -# -*- coding: utf-8 -*- | ||
2 | -from __future__ import unicode_literals | ||
3 | - | ||
4 | -from django.db import models, migrations | ||
5 | -import django.db.models.deletion | ||
6 | -import hitcounter.models | ||
7 | -from django.conf import settings | ||
8 | - | ||
9 | - | ||
10 | -class Migration(migrations.Migration): | ||
11 | - | ||
12 | - dependencies = [ | ||
13 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
14 | - ] | ||
15 | - | ||
16 | - operations = [ | ||
17 | - migrations.CreateModel( | ||
18 | - name='GitlabComment', | ||
19 | - fields=[ | ||
20 | - ('id', models.IntegerField(serialize=False, primary_key=True)), | ||
21 | - ('body', models.TextField()), | ||
22 | - ('created_at', models.DateTimeField(null=True, blank=True)), | ||
23 | - ('issue_comment', models.BooleanField(default=True)), | ||
24 | - ('parent_id', models.IntegerField(null=True)), | ||
25 | - ], | ||
26 | - options={ | ||
27 | - 'verbose_name': 'Gitlab Comments', | ||
28 | - 'verbose_name_plural': 'Gitlab Comments', | ||
29 | - }, | ||
30 | - bases=(models.Model,), | ||
31 | - ), | ||
32 | - migrations.CreateModel( | ||
33 | - name='GitlabGroup', | ||
34 | - fields=[ | ||
35 | - ('id', models.IntegerField(serialize=False, primary_key=True)), | ||
36 | - ('name', models.CharField(max_length=100)), | ||
37 | - ('path', models.CharField(max_length=100)), | ||
38 | - ('owner_id', models.IntegerField(null=True)), | ||
39 | - ], | ||
40 | - options={ | ||
41 | - 'verbose_name': 'Gitlab Group', | ||
42 | - 'verbose_name_plural': 'Gitlab Groups', | ||
43 | - }, | ||
44 | - bases=(models.Model,), | ||
45 | - ), | ||
46 | - migrations.CreateModel( | ||
47 | - name='GitlabIssue', | ||
48 | - fields=[ | ||
49 | - ('id', models.IntegerField(serialize=False, primary_key=True)), | ||
50 | - ('iid', models.IntegerField(null=True)), | ||
51 | - ('title', models.TextField()), | ||
52 | - ('description', models.TextField()), | ||
53 | - ('state', models.TextField()), | ||
54 | - ('created_at', models.DateTimeField(null=True, blank=True)), | ||
55 | - ], | ||
56 | - options={ | ||
57 | - 'verbose_name': 'Gitlab Issue', | ||
58 | - 'verbose_name_plural': 'Gitlab Issues', | ||
59 | - }, | ||
60 | - bases=(models.Model,), | ||
61 | - ), | ||
62 | - migrations.CreateModel( | ||
63 | - name='GitlabMergeRequest', | ||
64 | - fields=[ | ||
65 | - ('id', models.IntegerField(serialize=False, primary_key=True)), | ||
66 | - ('iid', models.IntegerField(null=True)), | ||
67 | - ('target_branch', models.TextField()), | ||
68 | - ('source_branch', models.TextField()), | ||
69 | - ('description', models.TextField()), | ||
70 | - ('title', models.TextField()), | ||
71 | - ('state', models.TextField()), | ||
72 | - ('created_at', models.DateTimeField(null=True, blank=True)), | ||
73 | - ], | ||
74 | - options={ | ||
75 | - 'verbose_name': 'Gitlab Merge Request', | ||
76 | - 'verbose_name_plural': 'Gitlab Merge Requests', | ||
77 | - }, | ||
78 | - bases=(models.Model,), | ||
79 | - ), | ||
80 | - migrations.CreateModel( | ||
81 | - name='GitlabProject', | ||
82 | - fields=[ | ||
83 | - ('id', models.IntegerField(serialize=False, primary_key=True)), | ||
84 | - ('description', models.TextField()), | ||
85 | - ('public', models.BooleanField(default=True)), | ||
86 | - ('name', models.TextField()), | ||
87 | - ('name_with_namespace', models.TextField()), | ||
88 | - ('created_at', models.DateTimeField(blank=True)), | ||
89 | - ('last_activity_at', models.DateTimeField(blank=True)), | ||
90 | - ('path_with_namespace', models.TextField(null=True, blank=True)), | ||
91 | - ], | ||
92 | - options={ | ||
93 | - 'verbose_name': 'Gitlab Project', | ||
94 | - 'verbose_name_plural': 'Gitlab Projects', | ||
95 | - }, | ||
96 | - bases=(models.Model, hitcounter.models.HitCounterModelMixin), | ||
97 | - ), | ||
98 | - migrations.AddField( | ||
99 | - model_name='gitlabmergerequest', | ||
100 | - name='project', | ||
101 | - field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='gitlab.GitlabProject', null=True), | ||
102 | - preserve_default=True, | ||
103 | - ), | ||
104 | - migrations.AddField( | ||
105 | - model_name='gitlabmergerequest', | ||
106 | - name='user', | ||
107 | - field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True), | ||
108 | - preserve_default=True, | ||
109 | - ), | ||
110 | - migrations.AddField( | ||
111 | - model_name='gitlabissue', | ||
112 | - name='project', | ||
113 | - field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='gitlab.GitlabProject', null=True), | ||
114 | - preserve_default=True, | ||
115 | - ), | ||
116 | - migrations.AddField( | ||
117 | - model_name='gitlabissue', | ||
118 | - name='user', | ||
119 | - field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True), | ||
120 | - preserve_default=True, | ||
121 | - ), | ||
122 | - migrations.AddField( | ||
123 | - model_name='gitlabcomment', | ||
124 | - name='project', | ||
125 | - field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='gitlab.GitlabProject', null=True), | ||
126 | - preserve_default=True, | ||
127 | - ), | ||
128 | - migrations.AddField( | ||
129 | - model_name='gitlabcomment', | ||
130 | - name='user', | ||
131 | - field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True), | ||
132 | - preserve_default=True, | ||
133 | - ), | ||
134 | - ] |
colab/plugins/gitlab/migrations/__init__.py
colab/plugins/gitlab/models.py
@@ -1,177 +0,0 @@ | @@ -1,177 +0,0 @@ | ||
1 | -from django.db import models | ||
2 | -from django.utils.translation import ugettext_lazy as _ | ||
3 | -from colab.plugins.utils.models import Collaboration | ||
4 | -from hitcounter.models import HitCounterModelMixin | ||
5 | - | ||
6 | - | ||
7 | -class GitlabProject(models.Model, HitCounterModelMixin): | ||
8 | - | ||
9 | - id = models.IntegerField(primary_key=True) | ||
10 | - description = models.TextField() | ||
11 | - public = models.BooleanField(default=True) | ||
12 | - name = models.TextField() | ||
13 | - name_with_namespace = models.TextField() | ||
14 | - created_at = models.DateTimeField(blank=True) | ||
15 | - last_activity_at = models.DateTimeField(blank=True) | ||
16 | - path_with_namespace = models.TextField(blank=True, null=True) | ||
17 | - | ||
18 | - @property | ||
19 | - def namespace(self): | ||
20 | - return self.path_with_namespace.split('/')[0] | ||
21 | - | ||
22 | - @property | ||
23 | - def url(self): | ||
24 | - return u'/gitlab/{}'.format(self.path_with_namespace) | ||
25 | - | ||
26 | - class Meta: | ||
27 | - verbose_name = _('Gitlab Project') | ||
28 | - verbose_name_plural = _('Gitlab Projects') | ||
29 | - | ||
30 | - | ||
31 | -class GitlabGroup(models.Model): | ||
32 | - id = models.IntegerField(primary_key=True) | ||
33 | - name = models.CharField(max_length=100) | ||
34 | - path = models.CharField(max_length=100) | ||
35 | - owner_id = models.IntegerField(null=True) | ||
36 | - | ||
37 | - def __unicode__(self): | ||
38 | - return u'{}'.format(self.path) | ||
39 | - | ||
40 | - @property | ||
41 | - def projects(self): | ||
42 | - projects = GitlabProject.objects.all() | ||
43 | - result = list() | ||
44 | - for project in projects: | ||
45 | - if self.path in project.namespace: | ||
46 | - result.append(project) | ||
47 | - return result | ||
48 | - | ||
49 | - @property | ||
50 | - def url(self): | ||
51 | - return u'/gitlab/groups/{}'.format(self.path) | ||
52 | - | ||
53 | - class Meta: | ||
54 | - verbose_name = _('Gitlab Group') | ||
55 | - verbose_name_plural = _('Gitlab Groups') | ||
56 | - | ||
57 | - | ||
58 | -class GitlabMergeRequest(Collaboration): | ||
59 | - | ||
60 | - id = models.IntegerField(primary_key=True) | ||
61 | - iid = models.IntegerField(null=True) | ||
62 | - target_branch = models.TextField() | ||
63 | - source_branch = models.TextField() | ||
64 | - project = models.ForeignKey(GitlabProject, null=True, | ||
65 | - on_delete=models.SET_NULL) | ||
66 | - description = models.TextField() | ||
67 | - title = models.TextField() | ||
68 | - state = models.TextField() | ||
69 | - created_at = models.DateTimeField(blank=True, null=True) | ||
70 | - | ||
71 | - @property | ||
72 | - def modified(self): | ||
73 | - return self.created_at | ||
74 | - | ||
75 | - @property | ||
76 | - def tag(self): | ||
77 | - return self.state | ||
78 | - | ||
79 | - type = u'merge_request' | ||
80 | - icon_name = u'file' | ||
81 | - | ||
82 | - @property | ||
83 | - def url(self): | ||
84 | - return u'/gitlab/{}/merge_requests/{}'.format( | ||
85 | - self.project.path_with_namespace, self.iid) | ||
86 | - | ||
87 | - def get_author(self): | ||
88 | - return self.user | ||
89 | - | ||
90 | - class Meta: | ||
91 | - verbose_name = _('Gitlab Merge Request') | ||
92 | - verbose_name_plural = _('Gitlab Merge Requests') | ||
93 | - | ||
94 | - | ||
95 | -class GitlabIssue(Collaboration): | ||
96 | - | ||
97 | - id = models.IntegerField(primary_key=True) | ||
98 | - iid = models.IntegerField(null=True) | ||
99 | - project = models.ForeignKey(GitlabProject, null=True, | ||
100 | - on_delete=models.SET_NULL) | ||
101 | - title = models.TextField() | ||
102 | - description = models.TextField() | ||
103 | - | ||
104 | - state = models.TextField() | ||
105 | - created_at = models.DateTimeField(blank=True, null=True) | ||
106 | - | ||
107 | - icon_name = u'align-right' | ||
108 | - type = u'gitlab_issue' | ||
109 | - | ||
110 | - @property | ||
111 | - def modified(self): | ||
112 | - return self.created_at | ||
113 | - | ||
114 | - @property | ||
115 | - def url(self): | ||
116 | - return u'/gitlab/{}/issues/{}'.format( | ||
117 | - self.project.path_with_namespace, self.iid) | ||
118 | - | ||
119 | - class Meta: | ||
120 | - verbose_name = _('Gitlab Issue') | ||
121 | - verbose_name_plural = _('Gitlab Issues') | ||
122 | - | ||
123 | - | ||
124 | -class GitlabComment(Collaboration): | ||
125 | - | ||
126 | - id = models.IntegerField(primary_key=True) | ||
127 | - body = models.TextField() | ||
128 | - created_at = models.DateTimeField(blank=True, null=True) | ||
129 | - issue_comment = models.BooleanField(default=True) | ||
130 | - | ||
131 | - project = models.ForeignKey(GitlabProject, null=True, | ||
132 | - on_delete=models.SET_NULL) | ||
133 | - | ||
134 | - parent_id = models.IntegerField(null=True) | ||
135 | - type = u'comment' | ||
136 | - | ||
137 | - @property | ||
138 | - def modified(self): | ||
139 | - return self.created_at | ||
140 | - | ||
141 | - @property | ||
142 | - def title(self): | ||
143 | - if self.issue_comment: | ||
144 | - issue = GitlabIssue.objects.get(id=self.parent_id) | ||
145 | - return issue.title | ||
146 | - else: | ||
147 | - merge_request = GitlabMergeRequest.objects.get(id=self.parent_id) | ||
148 | - return merge_request.title | ||
149 | - | ||
150 | - icon_name = u'align-right' | ||
151 | - | ||
152 | - @property | ||
153 | - def description(self): | ||
154 | - return self.body | ||
155 | - | ||
156 | - @property | ||
157 | - def tag(self): | ||
158 | - if self.issue_comment: | ||
159 | - issue = GitlabIssue.objects.get(id=self.parent_id) | ||
160 | - return issue.state | ||
161 | - else: | ||
162 | - merge_request = GitlabMergeRequest.objects.get(id=self.parent_id) | ||
163 | - return merge_request.state | ||
164 | - | ||
165 | - @property | ||
166 | - def url(self): | ||
167 | - if self.issue_comment: | ||
168 | - url_str = u'/gitlab/{}/issues/{}#notes_{}' | ||
169 | - else: | ||
170 | - url_str = u'/gitlab/{}/merge_requests/{}#notes_{}' | ||
171 | - | ||
172 | - return url_str.format(self.project.path_with_namespace, | ||
173 | - self.parent_id, self.id) | ||
174 | - | ||
175 | - class Meta: | ||
176 | - verbose_name = _('Gitlab Comments') | ||
177 | - verbose_name_plural = _('Gitlab Comments') |
colab/plugins/gitlab/search_indexes.py
@@ -1,120 +0,0 @@ | @@ -1,120 +0,0 @@ | ||
1 | -# -*- coding: utf-8 -*- | ||
2 | - | ||
3 | -import string | ||
4 | - | ||
5 | -from haystack import indexes | ||
6 | -from haystack.utils import log as logging | ||
7 | - | ||
8 | -from .models import (GitlabProject, GitlabMergeRequest, | ||
9 | - GitlabIssue, GitlabComment) | ||
10 | - | ||
11 | - | ||
12 | -logger = logging.getLogger('haystack') | ||
13 | - | ||
14 | -# The string maketrans always return a string encoded with latin1 | ||
15 | -# http://stackoverflow.com/questions/1324067/how-do-i-get-str-translate-to-work-with-unicode-strings | ||
16 | -table = string.maketrans( | ||
17 | - string.punctuation, | ||
18 | - '.' * len(string.punctuation) | ||
19 | -).decode('latin1') | ||
20 | - | ||
21 | - | ||
22 | -class GitlabProjectIndex(indexes.SearchIndex, indexes.Indexable): | ||
23 | - text = indexes.CharField(document=True, use_template=False, stored=False) | ||
24 | - title = indexes.CharField(model_attr='name') | ||
25 | - description = indexes.CharField(model_attr='description', null=True) | ||
26 | - tag = indexes.CharField() | ||
27 | - url = indexes.CharField(model_attr='url', indexed=False) | ||
28 | - icon_name = indexes.CharField() | ||
29 | - type = indexes.CharField() | ||
30 | - created = indexes.DateTimeField(model_attr='created_at', null=True) | ||
31 | - | ||
32 | - def prepare_tag(self, obj): | ||
33 | - return "{}".format(obj.name_with_namespace.split('/')[0].strip()) | ||
34 | - | ||
35 | - def prepare_icon_name(self, obj): | ||
36 | - return u'file' | ||
37 | - | ||
38 | - def get_ful_name(self): | ||
39 | - self.objs.name | ||
40 | - | ||
41 | - def get_model(self): | ||
42 | - return GitlabProject | ||
43 | - | ||
44 | - def prepare_type(self, obj): | ||
45 | - return u'gitlab' | ||
46 | - | ||
47 | - | ||
48 | -class GitlabMergeRequestIndex(indexes.SearchIndex, indexes.Indexable): | ||
49 | - | ||
50 | - text = indexes.CharField(document=True, use_template=False, stored=False) | ||
51 | - title = indexes.CharField(model_attr='title') | ||
52 | - description = indexes.CharField(model_attr='description') | ||
53 | - tag = indexes.CharField(model_attr='state') | ||
54 | - url = indexes.CharField(model_attr='url', indexed=False) | ||
55 | - icon_name = indexes.CharField() | ||
56 | - type = indexes.CharField(model_attr='type') | ||
57 | - | ||
58 | - modified_by = indexes.CharField(model_attr='modified_by', null=True) | ||
59 | - modified_by_url = indexes.CharField(model_attr='modified_by_url', | ||
60 | - null=True) | ||
61 | - modified = indexes.DateTimeField(model_attr='created_at', null=True) | ||
62 | - | ||
63 | - def get_model(self): | ||
64 | - return GitlabMergeRequest | ||
65 | - | ||
66 | - def prepare_icon_name(self, obj): | ||
67 | - return u'file' | ||
68 | - | ||
69 | - def prepare_type(self, obj): | ||
70 | - return u'merge_request' | ||
71 | - | ||
72 | - | ||
73 | -class GitlabIssueIndex(indexes.SearchIndex, indexes.Indexable): | ||
74 | - | ||
75 | - text = indexes.CharField(document=True, use_template=False, stored=False) | ||
76 | - title = indexes.CharField(model_attr='title') | ||
77 | - description = indexes.CharField(model_attr='description') | ||
78 | - tag = indexes.CharField(model_attr='state') | ||
79 | - url = indexes.CharField(model_attr='url', indexed=False) | ||
80 | - icon_name = indexes.CharField() | ||
81 | - type = indexes.CharField(model_attr='type') | ||
82 | - | ||
83 | - modified_by = indexes.CharField(model_attr='modified_by', null=True) | ||
84 | - modified_by_url = indexes.CharField(model_attr='modified_by_url', | ||
85 | - null=True) | ||
86 | - modified = indexes.DateTimeField(model_attr='created_at', null=True) | ||
87 | - | ||
88 | - def get_model(self): | ||
89 | - return GitlabIssue | ||
90 | - | ||
91 | - def prepare_icon_name(self, obj): | ||
92 | - return u'align-right' | ||
93 | - | ||
94 | - def prepare_type(self, obj): | ||
95 | - return u'merge_request' | ||
96 | - | ||
97 | - | ||
98 | -class GitlabCommentIndex(indexes.SearchIndex, indexes.Indexable): | ||
99 | - | ||
100 | - text = indexes.CharField(document=True, use_template=False, stored=False) | ||
101 | - title = indexes.CharField(model_attr='title') | ||
102 | - description = indexes.CharField(model_attr='description') | ||
103 | - tag = indexes.CharField() | ||
104 | - url = indexes.CharField(model_attr='url', indexed=False) | ||
105 | - icon_name = indexes.CharField() | ||
106 | - type = indexes.CharField(model_attr='type') | ||
107 | - | ||
108 | - modified_by = indexes.CharField(model_attr='modified_by', null=True) | ||
109 | - modified_by_url = indexes.CharField(model_attr='modified_by_url', | ||
110 | - null=True) | ||
111 | - modified = indexes.DateTimeField(model_attr='created_at', null=True) | ||
112 | - | ||
113 | - def get_model(self): | ||
114 | - return GitlabComment | ||
115 | - | ||
116 | - def prepare_icon_name(self, obj): | ||
117 | - return u'align-right' | ||
118 | - | ||
119 | - def prepare_tag(self, obj): | ||
120 | - return obj.tag |
colab/plugins/gitlab/tasks.py
colab/plugins/gitlab/templates/proxy/gitlab.html
@@ -1,56 +0,0 @@ | @@ -1,56 +0,0 @@ | ||
1 | -{% extends 'base.html' %} | ||
2 | -{% load static from staticfiles %} | ||
3 | - | ||
4 | -{% block head_css %} | ||
5 | -<style> | ||
6 | - /* Reset left and with for .modal-dialog style (like gitlab does), | ||
7 | - the bootstrap.css one makes it small */ | ||
8 | - @media screen and (min-width: 768px) { | ||
9 | - .modal-dialog { | ||
10 | - left: auto; | ||
11 | - width: auto; | ||
12 | - } | ||
13 | - } | ||
14 | - div#main-content { | ||
15 | - margin-top: 65px; | ||
16 | - } | ||
17 | - | ||
18 | - div#main-content div.container { | ||
19 | - width: 1110px; | ||
20 | - } | ||
21 | - div#main-content div.flash-container{ | ||
22 | - width: 85%; | ||
23 | - } | ||
24 | - #breadcrumbs { | ||
25 | - border: 0 !important; | ||
26 | - } | ||
27 | - | ||
28 | - #right-top-nav { | ||
29 | - margin-right: 5em !important; | ||
30 | - } | ||
31 | -</style> | ||
32 | -{% endblock %} | ||
33 | - | ||
34 | -{% block head_js %} | ||
35 | -<script type="text/javascript"> | ||
36 | - jQuery(function(){ | ||
37 | - // bootstrap.css forces .hide {display:none!important}, and this makes | ||
38 | - // gitlab .hide elements NEVER have a display:block, so | ||
39 | - // instead of editing bootstrap.css, we just removed '.hide' css class and | ||
40 | - // toggled | ||
41 | - jQuery('.hide').each(function(){ | ||
42 | - display_status = this.style.display; | ||
43 | - jQuery(this).removeClass('hide'); | ||
44 | - if(display_status != 'block') | ||
45 | - this.style.display = 'none'; | ||
46 | - }) | ||
47 | - | ||
48 | - // Hit the SSH clone button to select it by default | ||
49 | - jQuery(".git-clone-holder .btn:contains('SSH')").click() | ||
50 | - | ||
51 | - }); | ||
52 | -</script> | ||
53 | -<script type="text/javascript" src="{% static 'third-party/bootstrap/js/bootstrap.min.js' %}"></script> | ||
54 | -<script type="text/javascript" src="{% static 'third-party/jquery.cookie.js' %}"></script> | ||
55 | -<script>jQuery.noConflict();</script> | ||
56 | -{% endblock %} |
colab/plugins/gitlab/tests/__init__.py
colab/plugins/gitlab/tests/data.py
@@ -1,98 +0,0 @@ | @@ -1,98 +0,0 @@ | ||
1 | -colab_apps = {'gitlab': | ||
2 | - {'menu_title': None, | ||
3 | - 'private_token': 'token', | ||
4 | - 'upstream': 'localhost', | ||
5 | - 'urls': | ||
6 | - {'include': 'colab.plugins.gitlab.urls', | ||
7 | - 'namespace': 'gitlab', | ||
8 | - 'prefix': 'gitlab/'}}} | ||
9 | - | ||
10 | -projects_json = [{"id": 32, | ||
11 | - "description": "Test Gitlab", | ||
12 | - "default_branch": "master", | ||
13 | - "public": True, | ||
14 | - "archived": False, | ||
15 | - "visibility_level": 20, | ||
16 | - "ssh_url_to_repo": "git@localhost/gitlabhq.git", | ||
17 | - "http_url_to_repo": "localhost/gitlabhq.git", | ||
18 | - "web_url": "localhost/gitlabhq", | ||
19 | - "name": "Gitlab", | ||
20 | - "name_with_namespace": "Test / Gitlab", | ||
21 | - "path": "gitlabhq"}] | ||
22 | - | ||
23 | -groups_json = [{"id": 23, | ||
24 | - "name": "Group 1", | ||
25 | - "path": "group-1", | ||
26 | - "owner_id": None}, | ||
27 | - {"id": 27, | ||
28 | - "name": "Group 2", | ||
29 | - "path": "group-2", | ||
30 | - "owner_id": None}] | ||
31 | - | ||
32 | -merge_json = [{"id": 7, | ||
33 | - "iid": 1, | ||
34 | - "project_id": 14, | ||
35 | - "title": "Merge Title", | ||
36 | - "description": "description", | ||
37 | - "state": "merged", | ||
38 | - "created_at": "2014-10-24T12:05:55.659Z", | ||
39 | - "updated_at": "2014-10-24T12:06:15.572Z", | ||
40 | - "target_branch": "master", | ||
41 | - "source_branch": "settings_fix", | ||
42 | - "upvotes": 0, | ||
43 | - "downvotes": 0, | ||
44 | - "author": {"name": "user", | ||
45 | - "username": "user", | ||
46 | - "id": 8, | ||
47 | - "state": "active", | ||
48 | - "avatar_url": "localhost"}, | ||
49 | - "assignee": {"name": "user", | ||
50 | - "username": "user", | ||
51 | - "id": 8, | ||
52 | - "state": "active", | ||
53 | - "avatar_url": "localhost"}, | ||
54 | - "source_project_id": 14, | ||
55 | - "target_project_id": 14, | ||
56 | - "labels": [], | ||
57 | - "milestone": None}] | ||
58 | - | ||
59 | -issues_json = [{"id": 8, | ||
60 | - "iid": 1, | ||
61 | - "project_id": 32, | ||
62 | - "title": "title", | ||
63 | - "description": "description", | ||
64 | - "state": "opened", | ||
65 | - "created_at": "2014-10-11T16:25:37.548Z", | ||
66 | - "updated_at": "2014-10-11T16:25:37.548Z", | ||
67 | - "labels": [], | ||
68 | - "milestone": None, | ||
69 | - "assignee": {"name": "name", | ||
70 | - "username": "username", | ||
71 | - "id": 2, | ||
72 | - "state": "active", | ||
73 | - "avatar_url": "avatar_url"}, | ||
74 | - "author": {"name": "name", | ||
75 | - "username": "user", | ||
76 | - "id": 2, | ||
77 | - "state": "active", | ||
78 | - "avatar_url": "avatar_url"}}] | ||
79 | - | ||
80 | -comment_mr_json = [{"id": 11, | ||
81 | - "body": "message body", | ||
82 | - "attachment": None, | ||
83 | - "author": {"name": "user", | ||
84 | - "username": "user", | ||
85 | - "id": 8, | ||
86 | - "state": "active", | ||
87 | - "avatar_url": "avatar_url"}, | ||
88 | - "created_at": "2014-10-25T14:43:54.863Z"}] | ||
89 | - | ||
90 | -comment_issue_json = [{"id": 447, | ||
91 | - "body": "message body", | ||
92 | - "attachment": None, | ||
93 | - "author": {"name": "user", | ||
94 | - "username": "user", | ||
95 | - "state": "active", | ||
96 | - "id": 8, | ||
97 | - "avatar_url": "avatar_url"}, | ||
98 | - "created_at": "2015-03-16T17:34:07.715Z"}] |
colab/plugins/gitlab/tests/test_data_importer.py
@@ -1,97 +0,0 @@ | @@ -1,97 +0,0 @@ | ||
1 | -from django.test import TestCase | ||
2 | -from django.test.utils import override_settings | ||
3 | -from ..data_importer import GitlabDataImporter | ||
4 | -from ..models import GitlabProject, GitlabIssue | ||
5 | -from mock import patch | ||
6 | -import data | ||
7 | -from dateutil.parser import parse | ||
8 | - | ||
9 | - | ||
10 | -class GitlabDataImporterTest(TestCase): | ||
11 | - | ||
12 | - fixtures = ["gitlab_associations"] | ||
13 | - | ||
14 | - @override_settings(COLAB_APPS=data.colab_apps) | ||
15 | - def setUp(self): | ||
16 | - self.api = GitlabDataImporter() | ||
17 | - | ||
18 | - def test_resquest_url(self): | ||
19 | - url = self.api.get_request_url('/gitlab/test/') | ||
20 | - expected = 'localhost/gitlab/test/?private_token=token' | ||
21 | - self.assertEqual(url, expected) | ||
22 | - | ||
23 | - def test_resquest_url_with_params(self): | ||
24 | - url = self.api.get_request_url('/gitlab/test/', param='param') | ||
25 | - expected = 'localhost/gitlab/test/?private_token=token¶m=param' | ||
26 | - self.assertEqual(url, expected) | ||
27 | - | ||
28 | - @patch.object(GitlabDataImporter, 'get_json_data') | ||
29 | - def test_fetch_projects(self, mock_json): | ||
30 | - mock_json.side_effect = [data.projects_json, []] | ||
31 | - | ||
32 | - projects = self.api.fetch_projects() | ||
33 | - self.assertEqual(len(projects), 1) | ||
34 | - | ||
35 | - self.assertEqual(projects[0].description, "Test Gitlab") | ||
36 | - self.assertEqual(projects[0].public, True) | ||
37 | - | ||
38 | - @patch.object(GitlabDataImporter, 'get_json_data') | ||
39 | - def test_fetch_groups(self, mock_json): | ||
40 | - mock_json.side_effect = [data.groups_json, []] | ||
41 | - | ||
42 | - groups = self.api.fetch_groups() | ||
43 | - self.assertEqual(len(groups), 2) | ||
44 | - self.assertEqual(groups[0].name, "Group 1") | ||
45 | - self.assertEqual(groups[1].name, "Group 2") | ||
46 | - | ||
47 | - self.assertEqual(groups[0].path, "group-1") | ||
48 | - self.assertEqual(groups[1].path, "group-2") | ||
49 | - | ||
50 | - @patch.object(GitlabDataImporter, 'get_json_data') | ||
51 | - def test_fetch_merge(self, mock_json): | ||
52 | - mock_json.side_effect = [data.merge_json, []] | ||
53 | - | ||
54 | - merges = self.api.fetch_merge_request([GitlabProject()]) | ||
55 | - self.assertEqual(len(merges), 1) | ||
56 | - self.assertEqual(merges[0].title, "Merge Title") | ||
57 | - self.assertEqual(merges[0].description, "description") | ||
58 | - self.assertEqual(merges[0].get_author().username, "user") | ||
59 | - | ||
60 | - @patch.object(GitlabDataImporter, 'get_json_data') | ||
61 | - def test_fetch_issues(self, mock_json): | ||
62 | - mock_json.side_effect = [data.issues_json, []] | ||
63 | - | ||
64 | - issues = self.api.fetch_issue([GitlabProject()]) | ||
65 | - assert mock_json.called | ||
66 | - self.assertEqual(len(issues), 1) | ||
67 | - self.assertEqual(issues[0].title, "title") | ||
68 | - self.assertEqual(issues[0].description, "description") | ||
69 | - self.assertEqual(issues[0].state, "opened") | ||
70 | - | ||
71 | - @patch.object(GitlabDataImporter, 'get_json_data') | ||
72 | - def test_fetch_comments_mr(self, mock_json): | ||
73 | - mock_json.side_effect = [data.comment_mr_json, []] | ||
74 | - | ||
75 | - comments_mr = self.api.fetch_comments_mr() | ||
76 | - self.assertEqual(len(comments_mr), 1) | ||
77 | - self.assertEqual(comments_mr[0].body, "message body") | ||
78 | - self.assertEqual(comments_mr[0].user.username, "user") | ||
79 | - | ||
80 | - @patch.object(GitlabDataImporter, 'get_json_data') | ||
81 | - def test_fetch_comments_issues(self, mock_json): | ||
82 | - mock_json.side_effect = [data.comment_issue_json, []] | ||
83 | - | ||
84 | - comments_issue = self.api.fetch_comments_issues() | ||
85 | - self.assertEqual(len(comments_issue), 1) | ||
86 | - self.assertEqual(comments_issue[0].body, "message body") | ||
87 | - self.assertEqual(comments_issue[0].user.username, "user") | ||
88 | - | ||
89 | - def test_fill_object_data(self): | ||
90 | - issue = GitlabIssue() | ||
91 | - | ||
92 | - self.api.fill_object_data(data.issues_json[0], issue) | ||
93 | - self.assertIsNotNone(issue.user) | ||
94 | - self.assertEqual(issue.user.username, "user") | ||
95 | - self.assertEqual(issue.created_at, parse("2014-10-11T16:25:37.548Z")) | ||
96 | - self.assertEqual(issue.project_id, 32) | ||
97 | - self.assertEqual(issue.title, "title") |
colab/plugins/gitlab/tests/test_gitlab.py
@@ -1,63 +0,0 @@ | @@ -1,63 +0,0 @@ | ||
1 | -""" | ||
2 | -Test User class. | ||
3 | -Objective: Test parameters, and behavior. | ||
4 | -""" | ||
5 | -from django.test import TestCase, Client | ||
6 | -from colab.plugins.gitlab.models import (GitlabProject, GitlabGroup, | ||
7 | - GitlabIssue, GitlabComment, | ||
8 | - GitlabMergeRequest) | ||
9 | - | ||
10 | - | ||
11 | -class GitlabTest(TestCase): | ||
12 | - | ||
13 | - fixtures = ['test_gitlab_data'] | ||
14 | - | ||
15 | - def setUp(self): | ||
16 | - self.client = Client() | ||
17 | - | ||
18 | - super(GitlabTest, self).setUp() | ||
19 | - | ||
20 | - def tearDown(self): | ||
21 | - pass | ||
22 | - | ||
23 | - def test_data_integrity(self): | ||
24 | - self.assertEqual(GitlabGroup.objects.all().count(), 1) | ||
25 | - self.assertEqual(GitlabProject.objects.all().count(), 2) | ||
26 | - self.assertEqual(GitlabMergeRequest.objects.all().count(), 2) | ||
27 | - self.assertEqual(GitlabIssue.objects.all().count(), 2) | ||
28 | - self.assertEqual(GitlabComment.objects.all().count(), 2) | ||
29 | - | ||
30 | - def test_project_url(self): | ||
31 | - self.assertEqual(GitlabProject.objects.get(id=1).url, | ||
32 | - '/gitlab/softwarepublico/colab') | ||
33 | - | ||
34 | - def test_project_group(self): | ||
35 | - project = GitlabProject.objects.get(id=1) | ||
36 | - self.assertEqual(project.name, 'colab') | ||
37 | - self.assertEqual(project.namespace, 'softwarepublico') | ||
38 | - | ||
39 | - def test_namespace_projects(self): | ||
40 | - group = GitlabGroup.objects.get(id=1) | ||
41 | - self.assertEqual(len(group.projects), 2) | ||
42 | - self.assertEqual(group.projects[0].name, 'colab') | ||
43 | - self.assertEqual(group.projects[1].name, 'colabinc') | ||
44 | - | ||
45 | - def test_merge_request_url(self): | ||
46 | - self.assertEqual(GitlabMergeRequest.objects.get(id=1).url, | ||
47 | - '/gitlab/softwarepublico/colab/merge_requests/1') | ||
48 | - self.assertEqual(GitlabMergeRequest.objects.get(id=2).url, | ||
49 | - '/gitlab/softwarepublico/colabinc/merge_requests/1') | ||
50 | - | ||
51 | - def test_issue_url(self): | ||
52 | - self.assertEqual(GitlabIssue.objects.get(id=1).url, | ||
53 | - '/gitlab/softwarepublico/colab/issues/1') | ||
54 | - self.assertEqual(GitlabIssue.objects.get(id=2).url, | ||
55 | - '/gitlab/softwarepublico/colabinc/issues/1') | ||
56 | - | ||
57 | - def test_comment_on_mr_url(self): | ||
58 | - url = '/gitlab/softwarepublico/colab/merge_requests/1#notes_1' | ||
59 | - self.assertEqual(GitlabComment.objects.get(id=1).url, url) | ||
60 | - | ||
61 | - def test_comment_on_issue_url(self): | ||
62 | - self.assertEqual(GitlabComment.objects.get(id=2).url, | ||
63 | - '/gitlab/softwarepublico/colab/issues/1#notes_2') |
colab/plugins/gitlab/urls.py
colab/plugins/gitlab/views.py
colab/urls.py
@@ -21,7 +21,6 @@ urlpatterns = patterns('', | @@ -21,7 +21,6 @@ urlpatterns = patterns('', | ||
21 | url(r'^colab/admin/', include(admin.site.urls)), | 21 | url(r'^colab/admin/', include(admin.site.urls)), |
22 | 22 | ||
23 | url(r'^archives/', include('colab.super_archives.urls')), | 23 | url(r'^archives/', include('colab.super_archives.urls')), |
24 | - url(r'^gitlab/', include('colab.plugins.gitlab.urls')), | ||
25 | url(r'^mezuro/', include('colab.plugins.mezuro.urls')), | 24 | url(r'^mezuro/', include('colab.plugins.mezuro.urls')), |
26 | url(r'^social/', include('colab.plugins.noosfero.urls')), | 25 | url(r'^social/', include('colab.plugins.noosfero.urls')), |
27 | 26 |
setup.py
@@ -24,10 +24,6 @@ REQUIREMENTS = [ | @@ -24,10 +24,6 @@ REQUIREMENTS = [ | ||
24 | 'django-taggit>=0.12.1', | 24 | 'django-taggit>=0.12.1', |
25 | 'html2text>=3.200.3', | 25 | 'html2text>=3.200.3', |
26 | 'chardet>=2.3.0', | 26 | 'chardet>=2.3.0', |
27 | - | ||
28 | - # Deps for gitlab plugin | ||
29 | - 'python-dateutil>=1.5', | ||
30 | - 'requests', | ||
31 | ] | 27 | ] |
32 | 28 | ||
33 | TEST_REQUIREMENTS = [ | 29 | TEST_REQUIREMENTS = [ |
tests/plugins.d/gitlab.py
@@ -1,39 +0,0 @@ | @@ -1,39 +0,0 @@ | ||
1 | -from django.utils.translation import ugettext_lazy as _ | ||
2 | - | ||
3 | -name = 'colab.plugins.gitlab' | ||
4 | -verbose_name = 'Gitlab Proxy' | ||
5 | - | ||
6 | -upstream = 'localhost' | ||
7 | -#middlewares = [] | ||
8 | - | ||
9 | -menu = { | ||
10 | -'title': _('Code'), | ||
11 | -'links': ( | ||
12 | - (_('Public Projects'), 'public/projects'), | ||
13 | -), | ||
14 | -'auth_links': ( | ||
15 | - (_('Profile'), 'profile'), | ||
16 | - (_('New Project'), 'projects/new'), | ||
17 | - (_('Projects'), 'dashboard/projects'), | ||
18 | - (_('Groups'), 'profile/groups'), | ||
19 | - (_('Issues'), 'dashboard/issues'), | ||
20 | - (_('Merge Requests'), 'dashboard/merge_requests'), | ||
21 | - | ||
22 | -), | ||
23 | -} | ||
24 | - | ||
25 | - | ||
26 | -# dpaste: | ||
27 | -# dependencies: | ||
28 | -# - 'mptt' | ||
29 | -# urls: | ||
30 | -# include: 'dpaste.urls.dpaste' | ||
31 | -# prefix: '^paste/' | ||
32 | -# namespace: 'dpaste' | ||
33 | -# menu: | ||
34 | -# title: 'Dpaste' | ||
35 | -# links: | ||
36 | -# Public Projects: '/paste' | ||
37 | -# auth_links: | ||
38 | -# Profile: '/projects' | ||
39 | -# New Project: '/projects/new' |