1
Fork 0

rewrite urls to split them into seperate files

This commit is contained in:
Jake Howard 2016-01-26 22:41:43 +00:00
parent 8ca224f0ff
commit a2a753cac3
18 changed files with 78 additions and 54 deletions

View file

@ -37,19 +37,19 @@ class ReverserTestCase(TestCase):
class MarkdownViewTestCase(TestCase): class MarkdownViewTestCase(TestCase):
def test_accessable(self): def test_accessable(self):
response = self.client.get(reverse('pages:projects', args=['test'])) response = self.client.get(reverse('projects:project', args=['test']))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_parsing(self): def test_parsing(self):
response = self.client.get(reverse('pages:projects', args=['test'])) response = self.client.get(reverse('projects:project', args=['test']))
self.assertContains(response, '<h1>Testing</h1>') self.assertContains(response, '<h1>Testing</h1>')
def test_template_engine(self): def test_template_engine(self):
response = self.client.get(reverse('pages:projects', args=['test'])) response = self.client.get(reverse('projects:project', args=['test']))
self.assertContains(response, reverse('pages:all-projects')) self.assertContains(response, reverse('projects:all'))
def test_invalid_template(self): def test_invalid_template(self):
response = self.client.get(reverse('pages:projects', args=['not-a-project'])) response = self.client.get(reverse('projects:project', args=['not-a-project']))
self.assertEqual(response.status_code, 404) self.assertEqual(response.status_code, 404)
@ -69,7 +69,7 @@ class WorkerTestCase(TestCase):
'to_email': 'info@theorangeone.net', 'to_email': 'info@theorangeone.net',
'context': data 'context': data
} }
self.client.post(reverse('pages:about'), data) self.client.post(reverse('about:index'), data)
self.assertEqual(Job.objects.count(), 1) self.assertEqual(Job.objects.count(), 1)
job = Job.objects.all()[0] job = Job.objects.all()[0]
self.assertEqual(job.workspace, workspace) self.assertEqual(job.workspace, workspace)

View file

@ -10,13 +10,13 @@ class IndexTestCase(TestCase):
class AboutWebsiteTestCase(TestCase): class AboutWebsiteTestCase(TestCase):
def test_accessable(self): def test_accessable(self):
response = self.client.get(reverse('pages:about-website')) response = self.client.get(reverse('about:website'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
class AboutIndexTestCase(TestCase): class AboutIndexTestCase(TestCase):
def test_accessable(self): def test_accessable(self):
response = self.client.get(reverse('pages:about')) response = self.client.get(reverse('about:index'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_email_send(self): def test_email_send(self):
@ -25,11 +25,11 @@ class AboutIndexTestCase(TestCase):
'name': 'Person', 'name': 'Person',
'message': 'Hi there, things.' 'message': 'Hi there, things.'
} }
response = self.client.post(reverse('pages:about'), data) response = self.client.post(reverse('about:index'), data)
self.assertRedirects(response, '/about/?sent') self.assertRedirects(response, '/about/?sent')
def test_success_message_shows(self): def test_success_message_shows(self):
response = self.client.get(reverse('pages:about') + '?sent') response = self.client.get(reverse('about:index') + '?sent')
self.assertContains(response, 'Already Sent') self.assertContains(response, 'Already Sent')
@ -47,19 +47,19 @@ class NoJavascriptTestCase(TestCase):
class AllProjectsTestCase(TestCase): class AllProjectsTestCase(TestCase):
def test_accessable(self): def test_accessable(self):
response = self.client.get(reverse('pages:all-projects')) response = self.client.get(reverse('projects:all'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
class RoboticsTestCase(TestCase): class RoboticsTestCase(TestCase):
def test_2015_index_accessable(self): def test_2015_index_accessable(self):
response = self.client.get(reverse('pages:robotics-2015-index')) response = self.client.get(reverse('robotics:2015-index'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_2014_index_accessable(self): def test_2014_index_accessable(self):
response = self.client.get(reverse('pages:robotics-2014-index')) response = self.client.get(reverse('robotics:2014-index'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_2015_robot_accessable(self): def test_2015_robot_accessable(self):
response = self.client.get(reverse('pages:robotics-2015-robot')) response = self.client.get(reverse('robotics:2015-robot'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)

View file

@ -1,19 +0,0 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^about/website/$', views.about.WebsiteView.as_view(), name='about-website'),
url(r'^about/me/$', views.about.MeView.as_view(), name='about-me'),
url(r'^about/$', views.about.IndexView.as_view(), name='about'),
url(r'^projects/all/$', views.projects.AllView.as_view(), name="all-projects"),
url(r'^projects/(?P<project>.+)/$', views.projects.ProjectView.as_view(), name="projects"),
url(r'^robotics/$', views.robotics.IndexView.as_view(), name="robotics-index"),
url(r'^robotics/2014/$', views.robotics.Index2014View.as_view(), name="robotics-2014-index"),
url(r'^robotics/2015/robot/$', views.robotics.Robot2015View.as_view(), name="robotics-2015-robot"),
url(r'^robotics/2015/$', views.robotics.Index2015View.as_view(), name="robotics-2015-index"),
url(r'^$', views.core.IndexView.as_view(), name='index')
]

View file

@ -0,0 +1 @@
from . import about, core, projects, robotics

View file

@ -0,0 +1,9 @@
from django.conf.urls import url
from project.pages.views import about
urlpatterns = [
url(r'^website/$', about.WebsiteView.as_view(), name='website'),
url(r'^me/$', about.MeView.as_view(), name='me'),
url(r'^$', about.IndexView.as_view(), name='index'),
]

View file

@ -0,0 +1,7 @@
from django.conf.urls import url
from project.pages.views import core
urlpatterns = [
url(r'^$', core.IndexView.as_view(), name='index')
]

View file

@ -0,0 +1,8 @@
from django.conf.urls import url
from project.pages.views import projects
urlpatterns = [
url(r'^projects/all/$', projects.AllView.as_view(), name="all"),
url(r'^projects/(?P<project>.+)/$', projects.ProjectView.as_view(), name="project")
]

View file

@ -0,0 +1,10 @@
from django.conf.urls import url
from project.pages.views import robotics
urlpatterns = [
url(r'^robotics/$', robotics.IndexView.as_view(), name="index"),
url(r'^robotics/2014/$', robotics.Index2014View.as_view(), name="2014-index"),
url(r'^robotics/2015/robot/$', robotics.Robot2015View.as_view(), name="2015-robot"),
url(r'^robotics/2015/$', robotics.Index2015View.as_view(), name="2015-index")
]

View file

@ -7,7 +7,11 @@ urlpatterns = [
url(r'^reverse/$', include(reverse_urls, namespace='reverser')), url(r'^reverse/$', include(reverse_urls, namespace='reverser')),
url(r'^404/', Custom404View.as_view(), name="404"), url(r'^404/', Custom404View.as_view(), name="404"),
url(r'^no-js/', NoJavascriptView.as_view(), name="no-js"), url(r'^no-js/', NoJavascriptView.as_view(), name="no-js"),
url(r'', include('project.pages.urls', namespace='pages')) url(r'^about/', include('project.pages.urls.about', namespace='about')),
url(r'^core/', include('project.pages.urls.core', namespace='core')),
url(r'^projects/', include('project.pages.urls.projects', namespace='projects')),
url(r'^robotics/', include('project.pages.urls.robotics', namespace='robotics')),
url(r'', include('project.pages.urls.core', namespace='pages'))
] ]
# handler404 = Custom404View # handler404 = Custom404View

View file

@ -7,7 +7,7 @@ const DATA = [
{ {
title: 'Custom PC', title: 'Custom PC',
text: 'Without my PCs, I wouldnt be able to do anything you see here.', text: 'Without my PCs, I wouldnt be able to do anything you see here.',
link: 'pages:about-me', link: 'about:me',
}, },
{ {
title: 'BSOD-Enabler', title: 'BSOD-Enabler',
@ -32,7 +32,7 @@ const DATA = [
{ {
title: 'Student Robotics', title: 'Student Robotics',
text: '', text: '',
link: 'pages:robotics-index', link: 'robotics:index',
} }
]; ];

View file

@ -18,11 +18,11 @@ export default class NavBar extends React.Component {
</ul> </ul>
<ul className="nav navbar-nav" id="navigation"> <ul className="nav navbar-nav" id="navigation">
<Dropdown title="Projects"> <Dropdown title="Projects">
<Item ident="pages:projects" args={['pithos']} icon="ion-social-freebsd-devil">Pithos</Item> <Item ident="projects:project" args={['pithos']} icon="ion-social-freebsd-devil">Pithos</Item>
<Item href="#" icon="ion-ios-monitor">BSOD Enabler</Item> <Item href="#" icon="ion-ios-monitor">BSOD Enabler</Item>
<Item href="#" icon="ion-chatbox-working">Hipchat Emoticons for All</Item> <Item href="#" icon="ion-chatbox-working">Hipchat Emoticons for All</Item>
<Item href="#" icon="ion-social-windows">Custom PC</Item> <Item href="#" icon="ion-social-windows">Custom PC</Item>
<Item ident="pages:all-projects" icon="ion-android-more-vertical">All Projects...</Item> <Item ident="projects:all" icon="ion-android-more-vertical">All Projects...</Item>
</Dropdown> </Dropdown>
<Dropdown title="Code"> <Dropdown title="Code">
<Item href="#" icon="ion-code-working">Code Challenges</Item> <Item href="#" icon="ion-code-working">Code Challenges</Item>
@ -30,7 +30,7 @@ export default class NavBar extends React.Component {
<Item href="#" icon="ion-ios-game-controller-a">The Wiki Game Solver</Item> <Item href="#" icon="ion-ios-game-controller-a">The Wiki Game Solver</Item>
</Dropdown> </Dropdown>
<Dropdown title="College"> <Dropdown title="College">
<Item ident="pages:robotics-index">Student Robotics</Item> <Item ident="robotics:index">Student Robotics</Item>
<Item href="#" icon="ion-cube">Attack on Blocks Game</Item> <Item href="#" icon="ion-cube">Attack on Blocks Game</Item>
<Item href="#">Student Server</Item> <Item href="#">Student Server</Item>
<Item href="#" icon="ion-ios-paper">EPQ</Item> <Item href="#" icon="ion-ios-paper">EPQ</Item>
@ -58,8 +58,8 @@ export default class NavBar extends React.Component {
</Dropdown> </Dropdown>
<Item href="#">Links</Item> <Item href="#">Links</Item>
<Dropdown title="About"> <Dropdown title="About">
<Item ident="pages:about-me" icon="ion-android-person">Me</Item> <Item ident="about:me" icon="ion-android-person">Me</Item>
<Item ident="pages:about-website" icon="">Website</Item> <Item ident="about:website" icon="">Website</Item>
<Item href="#" icon="ion-android-contacts">Contact Me</Item> <Item href="#" icon="ion-android-contacts">Contact Me</Item>
</Dropdown> </Dropdown>
</ul> </ul>

View file

@ -11,9 +11,12 @@
@media (min-width: @screen-md-min) { @media (min-width: @screen-md-min) {
margin-right: 23px; margin-right: 23px;
} }
&:not(.dropdown) > a {
padding-top: 12px;
}
& > a { & > a {
@media (min-width: @screen-md-min) { @media (min-width: @screen-md-min) {
padding: 15px 10px; padding: 10px 10px;
} }
@media (max-width: @screen-xs-max) { @media (max-width: @screen-xs-max) {
padding: 15px 15px; padding: 15px 15px;
@ -37,6 +40,7 @@
&.dropdown { &.dropdown {
top: 100%; top: 100%;
bottom: initial; bottom: initial;
height: @navbar-height;
} }
.open & { .open & {
opacity: 1; opacity: 1;
@ -49,7 +53,7 @@
.navbar { .navbar {
max-height: 52px; max-height: @navbar-height;
border-radius: 0; border-radius: 0;
.home-button a { .home-button a {
.transition(~"ease-in-out .3 all"); .transition(~"ease-in-out .3 all");
@ -85,7 +89,7 @@
&.align { &.align {
@media (min-width: @screen-sm) { @media (min-width: @screen-sm) {
position: absolute; position: absolute;
height: 52px; height: @navbar-height;
} }
@media (max-width: @screen-sm) { @media (max-width: @screen-sm) {
position: fixed; position: fixed;
@ -98,7 +102,7 @@
#navbar-anchor { #navbar-anchor {
position: absolute; position: absolute;
height: 52px; height: @navbar-height;
} }
@media (min-width: @screen-xs-max) { @media (min-width: @screen-xs-max) {
@ -124,7 +128,7 @@
@media (min-width: @screen-xs-max) { @media (min-width: @screen-xs-max) {
navbar + * { navbar + * {
margin-top: 52px; margin-top: @navbar-height;
} }
} }

View file

@ -142,7 +142,7 @@
@container-md: @container-desktop; @container-md: @container-desktop;
@container-large-desktop: (1140px + @grid-gutter-width); @container-large-desktop: (1140px + @grid-gutter-width);
@container-lg: @container-large-desktop; @container-lg: @container-large-desktop;
@navbar-height: 50px; @navbar-height: 52px;
@navbar-margin-bottom: @line-height-computed; @navbar-margin-bottom: @line-height-computed;
@navbar-border-radius: @border-radius-base; @navbar-border-radius: @border-radius-base;
@navbar-padding-horizontal: floor((@grid-gutter-width / 2)); @navbar-padding-horizontal: floor((@grid-gutter-width / 2));

View file

@ -21,7 +21,7 @@
Some info about my website, which clearly works well as you're using it right now! Some info about my website, which clearly works well as you're using it right now!
</p> </p>
<p> <p>
<a href="{% url 'pages:about-website' %}" class="btn btn-primary btn-block">More Info</a> <a href="{% url 'about:website' %}" class="btn btn-primary btn-block">More Info</a>
</p> </p>
</div> </div>
</div> </div>
@ -37,7 +37,7 @@
Some info about me. Although not very much. Because Privacy! Some info about me. Although not very much. Because Privacy!
</p> </p>
<p> <p>
<a href="{% url 'pages:about-me'%}" class="btn btn-primary btn-block">More Info</a> <a href="{% url 'about:me'%}" class="btn btn-primary btn-block">More Info</a>
</p> </p>
</div> </div>
</div> </div>

View file

@ -29,7 +29,7 @@
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<p class="triple"> <p class="triple">
<a href="{% url 'pages:about' %}">About</a> | <a href="https://github.com/RealOrangeOne/theorangeone.net" target="_blank">View Source</a> | <a href="">Contact</a> <a href="{% url 'about:index' %}">About</a> | <a href="https://github.com/RealOrangeOne/theorangeone.net" target="_blank">View Source</a> | <a href="">Contact</a>
<p> <p>
</div> </div>
</div> </div>

View file

@ -1,4 +1,4 @@
# Testing # Testing
This page is for testing only. This page is for testing only.
Please [check out my other projects]({% url 'pages:all-projects' %}). Please [check out my other projects]({% url 'projects:all' %}).

View file

@ -35,7 +35,7 @@
<div class="col-sm-4"> <div class="col-sm-4">
<div class="list-group"> <div class="list-group">
<a class="list-group-item active h4">Quick Links</a> <a class="list-group-item active h4">Quick Links</a>
<a href="{% url 'pages:robotics-2015-robot' %}" class="list-group-item">The Robot - A.L.I.C.E</a> <a href="{% url 'robotics:2015-robot' %}" class="list-group-item">The Robot - A.L.I.C.E</a>
<a href="#" class="list-group-item">The Code</a> <a href="#" class="list-group-item">The Code</a>
<a href="#" class="list-group-item">Gallery</a> <a href="#" class="list-group-item">Gallery</a>
<a href="#" class="list-group-item">Blog</a> <a href="#" class="list-group-item">Blog</a>

View file

@ -24,7 +24,7 @@
<div class="caption"> <div class="caption">
<h2>Student Robotics 2014</h2> <h2>Student Robotics 2014</h2>
<p><strong>Robot Name:</strong> Lucy</p> <p><strong>Robot Name:</strong> Lucy</p>
<p><a href="{% url 'pages:robotics-2014-index' %}" class="btn btn-srobo btn-block">More Info</a></p> <p><a href="{% url 'robotics:2014-index' %}" class="btn btn-srobo btn-block">More Info</a></p>
</div> </div>
</div> </div>
</div> </div>
@ -34,7 +34,7 @@
<div class="caption"> <div class="caption">
<h2>Student Robotics 2015</h2> <h2>Student Robotics 2015</h2>
<p><strong>Robot Name : </strong> A.L.I.C.E <small>(<strong>A</strong>utonomous <strong>L</strong>ogistics and <strong>I</strong>nevitable <strong>C</strong>ollision <strong>E</strong>ngine)</small></p> <p><strong>Robot Name : </strong> A.L.I.C.E <small>(<strong>A</strong>utonomous <strong>L</strong>ogistics and <strong>I</strong>nevitable <strong>C</strong>ollision <strong>E</strong>ngine)</small></p>
<p><a href="{% url 'pages:robotics-2015-index' %}" class="btn btn-srobo btn-block" >More Info</a></p> <p><a href="{% url 'robotics:2015-index' %}" class="btn btn-srobo btn-block" >More Info</a></p>
</div> </div>
</div> </div>
</div> </div>