Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect to GitHub pages site #956

Open
wants to merge 3 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ Go
[here](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pulls?q=is%3Apr+is%3Aclosed)
for a complete commit history.

Release 1.7.8 on 2019-01-22
----------------------------
**Major Changes**
- None

**Minor Changes**
- [#956](https://github.com/ospc-org/ospc.org/pull/956) - Redirect to GitHub pages site - Hank Doupe and Peter Metz

**Bug Fixes**
- None

Release 1.7.7 on 2019-01-15
----------------------------
**Major Changes**
Expand Down
30 changes: 18 additions & 12 deletions webapp/apps/pages/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@


class PageViewsTests(TestCase):
def test_about(self):
resp = self.client.get('/about/')
self.assertEqual(resp.status_code, 200)

def test_home(self):
def test_redirects(self):
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)

def test_news(self):
resp = self.client.get('/news/')
self.assertEqual(resp.status_code, 302)

def test_subscribed(self):
resp = self.client.get('/subscribed/')
self.assertEqual(resp.status_code, 200)
extensions = [
"portfolio",
"team",
"newsletter",
"newsletter01092019",
"newsletter12192018",
"newsletter12052018",
"newsletter11152018",
"newsletter11022018",
"signup",
"subscribed",
"donate",
]

for ext in extensions:
resp = self.client.get(f"/{ext}/")
self.assertEqual(resp.status_code, 302)
34 changes: 27 additions & 7 deletions webapp/apps/pages/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
from django.conf.urls import patterns, include, url

from .views import (homepage, aboutpage, newspage, gallerypage, hellopage,
embedpage, widgetpage, newsdetailpage,
apps_landing_page, border_adjustment_plot, docspage,
gettingstartedpage, subscribed)
from .views import (
# gh pages
homepage, aboutpage, portfoliopage, teampage,
newsletterpage, newsletter0page, newsletter1page,
newsletter2page, newsletter3page, newsletter4page,
signuppage, subscribedpage, donatepage,

newspage, gallerypage, hellopage,
embedpage, widgetpage, newsdetailpage,
apps_landing_page, border_adjustment_plot, docspage,
gettingstartedpage, subscribed)

urlpatterns = [
url(r'^$', homepage, name='home'), # url(r'^apps/$', apps_landing_page, name='apps'),

# github pages redirects
url(r'^$', homepage, name='home'),
url(r'^about/$', aboutpage, name='about'),
url(r'^portfolio/$', aboutpage, name='portfolio'),
url(r'^team/$', teampage, name='team'),
url(r'^newsletter/$', newsletterpage, name='newsletter'),
url(r'^newsletter01092019/$', newsletter0page, name='newsletter0'),
url(r'^newsletter12192018/$', newsletter1page, name='newsletter1'),
url(r'^newsletter12052018/$', newsletter2page, name='newsletter2'),
url(r'^newsletter11152018/$', newsletter3page, name='newsletter3'),
url(r'^newsletter11022018/$', newsletter4page, name='newsletter4'),
url(r'^signup/$', signuppage, name="signup"),
url(r'^subscribed/$', subscribedpage, name="subscribed"),
url(r'^donate/$', donatepage, name="donate"),


url(r'^getting-started/$', gettingstartedpage, name='gettingstartedpage'),
url(r'^subscribed/$', subscribed, name='subscribed'),
url(r'^hello/$', hellopage, name='hello'),
url(r'^gallery/$', gallerypage, name='gallery'),
url(r'^news/$', newspage, name='news'),
url(r'^news/news-detail$', newsdetailpage, name='newsdetail'),
url(r'^gallery/(?P<widget_id>\w+)/$', widgetpage),
url(r'^gallery/embed/(?P<widget_id>\w+)/$', embedpage),
Expand Down
93 changes: 61 additions & 32 deletions webapp/apps/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,69 @@
TAXCALC_VERSION = taxcalc.__version__

BLOG_URL = os.environ.get('BLOG_URL', 'www.ospc.org')
GH_PAGES_URL = "https://ospc-org.github.io"
EMAIL_DEFAULT = '1'

# GH Pages redirect views:
# https://ospc-org.github.io/#about
# https://ospc-org.github.io/portfolio/
# https://ospc-org.github.io/team/
# https://ospc-org.github.io/newsletter/
# https://ospc-org.github.io/newsletter01092019/
# https://ospc-org.github.io/newsletter12192018/
# https://ospc-org.github.io/newsletter12052018/
# https://ospc-org.github.io/newsletter11152018/
# https://ospc-org.github.io/newsletter11022018/
# https://ospc-org.github.io/signup/
# https://ospc-org.github.io/subscribed/
# https://ospc-org.github.io/donate/


def homepage(request):
return redirect(GH_PAGES_URL)

def aboutpage(request):
return redirect(GH_PAGES_URL + "/#about")

def teampage(request):
return redirect(GH_PAGES_URL + "/team/")

def portfoliopage(request):
return redirect(GH_PAGES_URL + "/portfolio/")

def newsletterpage(request):
return redirect(GH_PAGES_URL + "/newsletter/")

def newsletter0page(request):
return redirect(GH_PAGES_URL + "/newsletter01092019/")

def newsletter1page(request):
return redirect(GH_PAGES_URL + "/newsletter12192018/")

def newsletter2page(request):
return redirect(GH_PAGES_URL + "/newsletter12052018/")

def newsletter3page(request):
return redirect(GH_PAGES_URL + "/newsletter11152018/")

def newsletter4page(request):
return redirect(GH_PAGES_URL + "/newsletter11022018/")

### add next newsletter here


def signuppage(request):
return redirect(GH_PAGES_URL + "/signup/")

def subscribedpage(request):
return redirect(GH_PAGES_URL + "/subscribed/")

def donatepage(request):
return redirect(GH_PAGES_URL + "/donate/")


#### end redirect views

def settings_context_processor(request):
return {'BLOG_URL': settings.BLOG_URL}

Expand All @@ -42,38 +103,6 @@ def subscribed(request):
def check_email(request):
return render(request, 'register/please-check-email.html', {})

def homepage(request):
form = subscribeform(request)
csrf_token = csrf(request)
if request.method == 'POST' and form.is_valid():
return check_email(request)

test = render(request, 'pages/home_content.html', {
'csrv_token': csrf(request)['csrf_token'],
'email_form': form,
'section': {
'active_nav': 'home',
'title': 'Welcome to the Open Source Policy Center',
},
'username': request.user
})

return test

def aboutpage(request):
form = subscribeform(request)
if request.method == 'POST' and form.is_valid():
return check_email(request)
test_1 = render(request, 'pages/about.html', {
'csrv_token': csrf(request)['csrf_token'],
'email_form': form,
'section': {
'active_nav': 'about',
'title': 'About',
}
})
return test_1

def gallerypage(request):
return render(request, 'pages/gallery.html', {
'manifest_url': os.environ.get('TAXPLOT_MANIFEST_URL'),
Expand Down
2 changes: 1 addition & 1 deletion webapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]


WEBAPP_VERSION = "1.7.7"
WEBAPP_VERSION = "1.7.8"

# Application definition

Expand Down