Skip to content

Commit 34313d3

Browse files
kvgargKVGarg
kvgarg
authored andcommitted
openhub/: Use openhub_django pypi package
Overriding the default openhub_django URLs so as to define new ones and pass the header and footer context of webpages and make openhub_django templates look similar to that of commuity website. Closes #285
1 parent 577b609 commit 34313d3

File tree

11 files changed

+276
-128
lines changed

11 files changed

+276
-128
lines changed

.ci/build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ fi
4444

4545
# Run meta review system
4646
python manage.py run_meta_review_system
47+
# Run openhub system
48+
python manage.py import_openhub_data
4749

4850
rm _site/$ISSUES_JSON
4951

.coafile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[all]
22
files = **.py, **.js, **.sh
3-
ignore = .git/**, **/__pycache__/**, gci/client.py, */migrations/**, private/*, openhub/**, **/leaflet_dist/**
3+
ignore = .git/**, **/__pycache__/**, gci/client.py, */migrations/**, private/*, **/leaflet_dist/**
44
max_line_length = 80
55
use_spaces = True
66
preferred_quotation = '

.moban.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ packages:
1111
- gamification
1212
- ci_build
1313
- meta_review
14-
- model
1514
- unassigned_issues
1615

1716
dependencies:
@@ -24,6 +23,7 @@ dependencies:
2423
- git+https://gitlab.com/gitmate/open-source/IGitt.git@1fa5a0a21ea4fb8739d467c06972f748717adbdc
2524
- requests
2625
- git+https://github.com/andrewda/trav.git@ce805d12d3d1db0a51b1aa26bba9cd9ecc0d96b8
26+
- openhub-django~=0.1.0
2727
- python-dateutil
2828
- pillow
2929
- ruamel.yaml

.nocover.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ nocover_file_globs:
1010
- gsoc/*.py
1111
- ci_build/*.py
1212
- meta_review/handler.py
13-
- openhub/*.py
1413
# Optional coverage. Once off scripts.
1514
- inactive_issues/inactive_issues_scraper.py
1615
- unassigned_issues/unassigned_issues_scraper.py

community/settings.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,24 @@
1313
import os
1414
import sys
1515

16+
from community.git import get_api_key, get_org_name
17+
from community.config import TokenMissing
18+
1619
from .filters import NoDebugFilter
1720

1821
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1922
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2023

2124

25+
# Set Environment variables needed by OpenHub-Django package
26+
try:
27+
OH_TOKEN = get_api_key('OH')
28+
except TokenMissing:
29+
os.environ['OH_TOKEN'] = ''
30+
31+
ORG_NAME = get_org_name()
32+
os.environ['ORG_NAME'] = ORG_NAME
33+
2234
# Quick-start development settings - unsuitable for production
2335
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
2436

@@ -37,8 +49,7 @@
3749
'gci',
3850
'gsoc',
3951
'data',
40-
'openhub',
41-
'model',
52+
'openhub_django.apps.OpenhubDjangoConfig',
4253
'gamification',
4354
'meta_review',
4455
'django.contrib.contenttypes',

community/urls.py

+3-119
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
22
Community URL configuration.
33
"""
4-
4+
from django.conf.urls import url
5+
from django.urls import include
56
from django_distill import distill_url
67
from django.conf.urls.static import static
78
from django.conf import settings
@@ -14,27 +15,6 @@
1415
from gamification.views import GamificationResults
1516
from meta_review.views import ContributorsMetaReview
1617
from inactive_issues.inactive_issues_scraper import inactive_issues_json
17-
from openhub.views import index as openhub_index
18-
from model.views import index as model_index
19-
from openhub.models import (
20-
PortfolioProject,
21-
OutsideCommitter,
22-
AffiliatedCommitter,
23-
OutsideProject,
24-
Organization,
25-
)
26-
from model.views import (
27-
PortfolioProjectListView,
28-
PortfolioProjectDetailView,
29-
AffiliatedCommitterListView,
30-
AffiliatedCommitterDetailView,
31-
OrganizationListView,
32-
OrganizationDetailView,
33-
OutsideProjectListView,
34-
OutsideProjectDetailView,
35-
OutsideCommitterListView,
36-
OutsideCommitterDetailView,
37-
)
3818
from unassigned_issues.unassigned_issues_scraper import (
3919
unassigned_issues_activity_json,
4020
)
@@ -46,31 +26,6 @@ def get_index():
4626
return None
4727

4828

49-
def get_all_portfolioprojects():
50-
for portfolioproject in PortfolioProject.objects.all():
51-
yield {'pk': portfolioproject.id}
52-
53-
54-
def get_all_outsidecommitters():
55-
for outsidecommitter in OutsideCommitter.objects.all():
56-
yield {'pk': outsidecommitter.id}
57-
58-
59-
def get_all_outsideprojects():
60-
for outsideproject in OutsideProject.objects.all():
61-
yield {'pk': outsideproject.id}
62-
63-
64-
def get_all_affiliatedcommitters():
65-
for affiliatedcommitter in AffiliatedCommitter.objects.all():
66-
yield {'pk': affiliatedcommitter.id}
67-
68-
69-
def get_organization():
70-
for organization in Organization.objects.all():
71-
yield {'pk': organization.id}
72-
73-
7429
urlpatterns = [
7530
distill_url(
7631
r'^$', HomePageView.as_view(),
@@ -120,78 +75,6 @@ def get_organization():
12075
distill_func=get_index,
12176
distill_file='static/inactive-issues.json',
12277
),
123-
distill_url(
124-
r'openhub/$', openhub_index,
125-
name='community-openhub',
126-
distill_func=get_index,
127-
distill_file='openhub/index.html',
128-
),
129-
distill_url(
130-
r'model/$', model_index,
131-
name='community-model',
132-
distill_func=get_index,
133-
distill_file='model/index.html',
134-
),
135-
distill_url(
136-
r'model/openhub/outside_committers/$',
137-
OutsideCommitterListView.as_view(),
138-
name='outsidecommitters',
139-
distill_func=get_index,
140-
),
141-
distill_url(
142-
r'model/openhub/outside_committer/(?P<pk>\d+)/$',
143-
OutsideCommitterDetailView.as_view(),
144-
name='outsidecommitter-detail',
145-
distill_func=get_all_outsidecommitters,
146-
),
147-
distill_url(
148-
r'model/openhub/outside_projects/$',
149-
OutsideProjectListView.as_view(),
150-
name='outsideprojects',
151-
distill_func=get_index,
152-
),
153-
distill_url(
154-
r'model/openhub/outside_project/(?P<pk>\d+)/$',
155-
OutsideProjectDetailView.as_view(),
156-
name='outsideproject-detail',
157-
distill_func=get_all_outsideprojects,
158-
),
159-
distill_url(
160-
r'model/openhub/affiliated_committers/$',
161-
AffiliatedCommitterListView.as_view(),
162-
name='affiliatedcommitters',
163-
distill_func=get_index,
164-
),
165-
distill_url(
166-
r'model/openhub/affiliated_committer/(?P<pk>\d+)/$',
167-
AffiliatedCommitterDetailView.as_view(),
168-
name='affiliatedcommitter-detail',
169-
distill_func=get_all_affiliatedcommitters,
170-
),
171-
distill_url(
172-
r'model/openhub/portfolio_projects/$',
173-
PortfolioProjectListView.as_view(),
174-
name='portfolioprojects',
175-
distill_func=get_index,
176-
),
177-
distill_url(
178-
r'model/openhub/portfolio_project/(?P<pk>\d+)/$',
179-
PortfolioProjectDetailView.as_view(),
180-
name='portfolioproject-detail',
181-
distill_func=get_all_portfolioprojects,
182-
),
183-
distill_url(
184-
r'model/openhub/organization/$',
185-
OrganizationListView.as_view(),
186-
name='organization',
187-
distill_func=get_index,
188-
),
189-
distill_url(
190-
r'model/openhub/org/(?P<pk>\d+)/$',
191-
OrganizationDetailView.as_view(),
192-
name='org-detail',
193-
distill_func=get_organization,
194-
),
19578
distill_url(
19679
r'static/unassigned-issues.json', unassigned_issues_activity_json,
19780
name='unassigned_issues_activity_json',
@@ -204,4 +87,5 @@ def get_organization():
20487
distill_func=get_index,
20588
distill_file='gamification/index.html',
20689
),
90+
url(r'openhub/', include('openhub.urls'))
20791
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

openhub/urls.py

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
"""
2+
OpenHub-Django URL configuration.
3+
"""
4+
5+
from django_distill import distill_url
6+
7+
from openhub_django.models import (
8+
PortfolioProject,
9+
OutsideCommitter,
10+
AffiliatedCommitter,
11+
OutsideProject,
12+
Organization,
13+
)
14+
from .views import (
15+
Homepage,
16+
PortfolioProjectListView,
17+
PortfolioProjectDetailView,
18+
AffiliatedCommitterListView,
19+
AffiliatedCommitterDetailView,
20+
OrganizationListView,
21+
OrganizationDetailView,
22+
OutsideProjectListView,
23+
OutsideProjectDetailView,
24+
OutsideCommitterListView,
25+
OutsideCommitterDetailView,
26+
)
27+
28+
29+
def get_index():
30+
# The index URI regex, ^$, contains no parameters, named or otherwise.
31+
# You can simply just return nothing here.
32+
return None
33+
34+
35+
def get_all_portfolioprojects():
36+
for portfolioproject in PortfolioProject.objects.all():
37+
yield {'pk': portfolioproject.id}
38+
39+
40+
def get_all_outsidecommitters():
41+
for outsidecommitter in OutsideCommitter.objects.all():
42+
yield {'pk': outsidecommitter.id}
43+
44+
45+
def get_all_outsideprojects():
46+
for outsideproject in OutsideProject.objects.all():
47+
yield {'pk': outsideproject.id}
48+
49+
50+
def get_all_affiliatedcommitters():
51+
for affiliatedcommitter in AffiliatedCommitter.objects.all():
52+
yield {'pk': affiliatedcommitter.id}
53+
54+
55+
def get_organization():
56+
for organization in Organization.objects.all():
57+
yield {'pk': organization.id}
58+
59+
60+
urlpatterns = [
61+
distill_url(
62+
r'^$', Homepage.as_view(),
63+
name='community-openhub',
64+
distill_func=get_index,
65+
),
66+
distill_url(
67+
r'outside_committers/$',
68+
OutsideCommitterListView.as_view(),
69+
name='outsidecommitters',
70+
distill_func=get_index,
71+
),
72+
distill_url(
73+
r'outside_committer/(?P<pk>\d+)/$',
74+
OutsideCommitterDetailView.as_view(),
75+
name='outsidecommitter-detail',
76+
distill_func=get_all_outsidecommitters,
77+
),
78+
distill_url(
79+
r'outside_projects/$',
80+
OutsideProjectListView.as_view(),
81+
name='outsideprojects',
82+
distill_func=get_index,
83+
),
84+
distill_url(
85+
r'outside_project/(?P<pk>\d+)/$',
86+
OutsideProjectDetailView.as_view(),
87+
name='outsideproject-detail',
88+
distill_func=get_all_outsideprojects,
89+
),
90+
distill_url(
91+
r'affiliated_committers/$',
92+
AffiliatedCommitterListView.as_view(),
93+
name='affiliatedcommitters',
94+
distill_func=get_index,
95+
),
96+
distill_url(
97+
r'affiliated_committer/(?P<pk>\d+)/$',
98+
AffiliatedCommitterDetailView.as_view(),
99+
name='affiliatedcommitter-detail',
100+
distill_func=get_all_affiliatedcommitters,
101+
),
102+
distill_url(
103+
r'portfolio_projects/$',
104+
PortfolioProjectListView.as_view(),
105+
name='portfolioprojects',
106+
distill_func=get_index,
107+
),
108+
distill_url(
109+
r'portfolio_project/(?P<pk>\d+)/$',
110+
PortfolioProjectDetailView.as_view(),
111+
name='portfolioproject-detail',
112+
distill_func=get_all_portfolioprojects,
113+
),
114+
distill_url(
115+
r'organization/$',
116+
OrganizationListView.as_view(),
117+
name='organization',
118+
distill_func=get_index,
119+
),
120+
distill_url(
121+
r'org/(?P<pk>\d+)/$',
122+
OrganizationDetailView.as_view(),
123+
name='org-detail',
124+
distill_func=get_organization,
125+
),
126+
]

0 commit comments

Comments
 (0)