Skip to content

Commit

Permalink
openhub/: Use openhub_django pypi package
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kvgarg authored and KVGarg committed Aug 6, 2019
1 parent 577b609 commit 8daed65
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 128 deletions.
2 changes: 2 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ fi

# Run meta review system
python manage.py run_meta_review_system
# Run openhub system
python manage.py import_openhub_data

rm _site/$ISSUES_JSON

Expand Down
2 changes: 1 addition & 1 deletion .coafile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[all]
files = **.py, **.js, **.sh
ignore = .git/**, **/__pycache__/**, gci/client.py, */migrations/**, private/*, openhub/**, **/leaflet_dist/**
ignore = .git/**, **/__pycache__/**, gci/client.py, */migrations/**, private/*, **/leaflet_dist/**
max_line_length = 80
use_spaces = True
preferred_quotation = '
Expand Down
2 changes: 1 addition & 1 deletion .moban.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ packages:
- gamification
- ci_build
- meta_review
- model
- unassigned_issues

dependencies:
Expand All @@ -24,6 +23,7 @@ dependencies:
- git+https://gitlab.com/gitmate/open-source/IGitt.git@1fa5a0a21ea4fb8739d467c06972f748717adbdc
- requests
- git+https://github.com/andrewda/trav.git@ce805d12d3d1db0a51b1aa26bba9cd9ecc0d96b8
- openhub-django~=0.1.0
- python-dateutil
- pillow
- ruamel.yaml
Expand Down
1 change: 0 additions & 1 deletion .nocover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ nocover_file_globs:
- gsoc/*.py
- ci_build/*.py
- meta_review/handler.py
- openhub/*.py
# Optional coverage. Once off scripts.
- inactive_issues/inactive_issues_scraper.py
- unassigned_issues/unassigned_issues_scraper.py
Expand Down
15 changes: 13 additions & 2 deletions community/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,24 @@
import os
import sys

from community.git import get_api_key, get_org_name
from community.config import TokenMissing

from .filters import NoDebugFilter

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


# Set Environment variables needed by OpenHub-Django package
try:
OH_TOKEN = get_api_key('OH')
except TokenMissing:
os.environ['OH_TOKEN'] = ''

ORG_NAME = get_org_name()
os.environ['ORG_NAME'] = ORG_NAME

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

Expand All @@ -37,8 +49,7 @@
'gci',
'gsoc',
'data',
'openhub',
'model',
'openhub_django.apps.OpenhubDjangoConfig',
'gamification',
'meta_review',
'django.contrib.contenttypes',
Expand Down
122 changes: 3 additions & 119 deletions community/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Community URL configuration.
"""

from django.conf.urls import url
from django.urls import include
from django_distill import distill_url
from django.conf.urls.static import static
from django.conf import settings
Expand All @@ -14,27 +15,6 @@
from gamification.views import GamificationResults
from meta_review.views import ContributorsMetaReview
from inactive_issues.inactive_issues_scraper import inactive_issues_json
from openhub.views import index as openhub_index
from model.views import index as model_index
from openhub.models import (
PortfolioProject,
OutsideCommitter,
AffiliatedCommitter,
OutsideProject,
Organization,
)
from model.views import (
PortfolioProjectListView,
PortfolioProjectDetailView,
AffiliatedCommitterListView,
AffiliatedCommitterDetailView,
OrganizationListView,
OrganizationDetailView,
OutsideProjectListView,
OutsideProjectDetailView,
OutsideCommitterListView,
OutsideCommitterDetailView,
)
from unassigned_issues.unassigned_issues_scraper import (
unassigned_issues_activity_json,
)
Expand All @@ -46,31 +26,6 @@ def get_index():
return None


def get_all_portfolioprojects():
for portfolioproject in PortfolioProject.objects.all():
yield {'pk': portfolioproject.id}


def get_all_outsidecommitters():
for outsidecommitter in OutsideCommitter.objects.all():
yield {'pk': outsidecommitter.id}


def get_all_outsideprojects():
for outsideproject in OutsideProject.objects.all():
yield {'pk': outsideproject.id}


def get_all_affiliatedcommitters():
for affiliatedcommitter in AffiliatedCommitter.objects.all():
yield {'pk': affiliatedcommitter.id}


def get_organization():
for organization in Organization.objects.all():
yield {'pk': organization.id}


urlpatterns = [
distill_url(
r'^$', HomePageView.as_view(),
Expand Down Expand Up @@ -120,78 +75,6 @@ def get_organization():
distill_func=get_index,
distill_file='static/inactive-issues.json',
),
distill_url(
r'openhub/$', openhub_index,
name='community-openhub',
distill_func=get_index,
distill_file='openhub/index.html',
),
distill_url(
r'model/$', model_index,
name='community-model',
distill_func=get_index,
distill_file='model/index.html',
),
distill_url(
r'model/openhub/outside_committers/$',
OutsideCommitterListView.as_view(),
name='outsidecommitters',
distill_func=get_index,
),
distill_url(
r'model/openhub/outside_committer/(?P<pk>\d+)/$',
OutsideCommitterDetailView.as_view(),
name='outsidecommitter-detail',
distill_func=get_all_outsidecommitters,
),
distill_url(
r'model/openhub/outside_projects/$',
OutsideProjectListView.as_view(),
name='outsideprojects',
distill_func=get_index,
),
distill_url(
r'model/openhub/outside_project/(?P<pk>\d+)/$',
OutsideProjectDetailView.as_view(),
name='outsideproject-detail',
distill_func=get_all_outsideprojects,
),
distill_url(
r'model/openhub/affiliated_committers/$',
AffiliatedCommitterListView.as_view(),
name='affiliatedcommitters',
distill_func=get_index,
),
distill_url(
r'model/openhub/affiliated_committer/(?P<pk>\d+)/$',
AffiliatedCommitterDetailView.as_view(),
name='affiliatedcommitter-detail',
distill_func=get_all_affiliatedcommitters,
),
distill_url(
r'model/openhub/portfolio_projects/$',
PortfolioProjectListView.as_view(),
name='portfolioprojects',
distill_func=get_index,
),
distill_url(
r'model/openhub/portfolio_project/(?P<pk>\d+)/$',
PortfolioProjectDetailView.as_view(),
name='portfolioproject-detail',
distill_func=get_all_portfolioprojects,
),
distill_url(
r'model/openhub/organization/$',
OrganizationListView.as_view(),
name='organization',
distill_func=get_index,
),
distill_url(
r'model/openhub/org/(?P<pk>\d+)/$',
OrganizationDetailView.as_view(),
name='org-detail',
distill_func=get_organization,
),
distill_url(
r'static/unassigned-issues.json', unassigned_issues_activity_json,
name='unassigned_issues_activity_json',
Expand All @@ -204,4 +87,5 @@ def get_organization():
distill_func=get_index,
distill_file='gamification/index.html',
),
url(r'openhub/', include('openhub.urls'))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
126 changes: 126 additions & 0 deletions openhub/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""
OpenHub-Django URL configuration.
"""

from django_distill import distill_url

from openhub_django.models import (
PortfolioProject,
OutsideCommitter,
AffiliatedCommitter,
OutsideProject,
Organization,
)
from .views import (
Homepage,
PortfolioProjectListView,
PortfolioProjectDetailView,
AffiliatedCommitterListView,
AffiliatedCommitterDetailView,
OrganizationListView,
OrganizationDetailView,
OutsideProjectListView,
OutsideProjectDetailView,
OutsideCommitterListView,
OutsideCommitterDetailView,
)


def get_index():
# The index URI regex, ^$, contains no parameters, named or otherwise.
# You can simply just return nothing here.
return None


def get_all_portfolioprojects():
for portfolioproject in PortfolioProject.objects.all():
yield {'pk': portfolioproject.id}


def get_all_outsidecommitters():
for outsidecommitter in OutsideCommitter.objects.all():
yield {'pk': outsidecommitter.id}


def get_all_outsideprojects():
for outsideproject in OutsideProject.objects.all():
yield {'pk': outsideproject.id}


def get_all_affiliatedcommitters():
for affiliatedcommitter in AffiliatedCommitter.objects.all():
yield {'pk': affiliatedcommitter.id}


def get_organization():
for organization in Organization.objects.all():
yield {'pk': organization.id}


urlpatterns = [
distill_url(
r'^$', Homepage.as_view(),
name='community-openhub',
distill_func=get_index,
),
distill_url(
r'outside_committers/$',
OutsideCommitterListView.as_view(),
name='outsidecommitters',
distill_func=get_index,
),
distill_url(
r'outside_committer/(?P<pk>\d+)/$',
OutsideCommitterDetailView.as_view(),
name='outsidecommitter-detail',
distill_func=get_all_outsidecommitters,
),
distill_url(
r'outside_projects/$',
OutsideProjectListView.as_view(),
name='outsideprojects',
distill_func=get_index,
),
distill_url(
r'outside_project/(?P<pk>\d+)/$',
OutsideProjectDetailView.as_view(),
name='outsideproject-detail',
distill_func=get_all_outsideprojects,
),
distill_url(
r'affiliated_committers/$',
AffiliatedCommitterListView.as_view(),
name='affiliatedcommitters',
distill_func=get_index,
),
distill_url(
r'affiliated_committer/(?P<pk>\d+)/$',
AffiliatedCommitterDetailView.as_view(),
name='affiliatedcommitter-detail',
distill_func=get_all_affiliatedcommitters,
),
distill_url(
r'portfolio_projects/$',
PortfolioProjectListView.as_view(),
name='portfolioprojects',
distill_func=get_index,
),
distill_url(
r'portfolio_project/(?P<pk>\d+)/$',
PortfolioProjectDetailView.as_view(),
name='portfolioproject-detail',
distill_func=get_all_portfolioprojects,
),
distill_url(
r'organization/$',
OrganizationListView.as_view(),
name='organization',
distill_func=get_index,
),
distill_url(
r'org/(?P<pk>\d+)/$',
OrganizationDetailView.as_view(),
name='org-detail',
distill_func=get_organization,
),
]
Loading

0 comments on commit 8daed65

Please sign in to comment.