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

Add support of redirects #11

Merged
merged 14 commits into from
Dec 30, 2016
Merged

Add support of redirects #11

merged 14 commits into from
Dec 30, 2016

Conversation

tangochin
Copy link
Contributor

Added support of redirects from 404 through special middleware.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.3%) to 90.718% when pulling fe84e43 on tangochin:master into 7b290d5 on whyflyru:master.

@coveralls
Copy link

coveralls commented Dec 28, 2016

Coverage Status

Coverage increased (+0.3%) to 90.718% when pulling b97f3ef on tangochin:master into 7b290d5 on whyflyru:master.

@coveralls
Copy link

coveralls commented Dec 28, 2016

Coverage Status

Coverage increased (+0.3%) to 90.718% when pulling d3aba26 on tangochin:master into 7b290d5 on whyflyru:master.

@coveralls
Copy link

coveralls commented Dec 28, 2016

Coverage Status

Coverage increased (+0.3%) to 90.718% when pulling 891430a on tangochin:master into 7b290d5 on whyflyru:master.

@coveralls
Copy link

coveralls commented Dec 30, 2016

Coverage Status

Coverage increased (+0.3%) to 90.734% when pulling 0b60a20 on tangochin:master into 7b290d5 on whyflyru:master.

@coveralls
Copy link

coveralls commented Dec 30, 2016

Coverage Status

Coverage increased (+0.3%) to 90.75% when pulling 46259b8 on tangochin:master into 7b290d5 on whyflyru:master.

@coveralls
Copy link

coveralls commented Dec 30, 2016

Coverage Status

Coverage increased (+0.2%) to 90.625% when pulling e36acd4 on tangochin:master into 7b290d5 on whyflyru:master.

current_site = get_current_site(request)
subdomain = getattr(request, 'subdomain', '')

redirect_patterns = RedirectPattern.objects.filter(site=current_site, subdomain=subdomain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут можно сразу по url_pattern__regex поискать


for redirect_pattern in redirect_patterns:
if re.match(redirect_pattern.url_pattern, full_path):
Redirect.objects.get_or_create(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А в этом случае пользователь получит редикект? Или 404? Ведь RedirectFallbackMiddleware идет ДО данного middleware


for redirect_pattern in redirect_patterns:
if re.match(redirect_pattern.url_pattern, full_path):
Redirect.objects.get_or_create(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не особо понимаю смысла возможности создавать несколько Redirect (у тебя тут цикл ведь)

@varche1 varche1 merged commit a161b3c into whyflyru:master Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants