Skip to content

Commit

Permalink
Merge pull request #6 from josephmancuso/develop
Browse files Browse the repository at this point in the history
Adding new redirect functionality to the request object
  • Loading branch information
josephmancuso committed Jan 16, 2018
2 parents b699c11 + d945531 commit c6ce90a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
37 changes: 35 additions & 2 deletions masonite/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,42 @@ def user(self):
def redirect(self, route):
''' Redirect the user based on the route specified '''
self.redirect_url = route
return 'redirecting ...'
return self

def redirectTo(self, route):
''' Redirect to a named route '''
self.redirect_route = route
return 'redirecting ...'
return self

def back(self, input_parameter='back'):
''' Go to a named route with the back parameter '''
self.redirectTo(self.input(input_parameter))
return self

def compile_route_to_url(self):
''' Compile the route url into a usable url
Converts /url/@id into /url/1. Used for redirection
'''

# Split the url into a list
split_url = self.redirect_url.split('/')

# Start beginning of the new compiled url
compiled_url = '/'

# Iterate over the list
for url in split_url:

# if the url contains a parameter variable like @id:int
if '@' in url:
url = url.replace('@', '').replace(':int', '').replace(':string', '')
compiled_url += '/' + str(self.param(url))
else:
compiled_url += url

return compiled_url

def send(self, params):
''' With '''
self.set_params(params)
return self
2 changes: 1 addition & 1 deletion masonite/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self):
self.method_type = 'POST'
self.continueroute = True
self.url = False
self.exclude_list = False
self.exclude_list = []
self.output = False
self.model_obj = None

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'masonite.extensions',
'masonite.facades',
], # this must be the same as the name above
version='0.2.6',
version='0.2.7.1',
description='The core for the python framework',
author='Joseph Mancuso',
author_email='idmann509@gmail.com',
Expand Down

0 comments on commit c6ce90a

Please sign in to comment.