# Path: accounts/views.py
# def registration(request):
#     if request.user.is_authenticated():
#         return HttpResponseRedirect(reverse('home'))
#     if request.method == 'POST':
#         form = RegistrationForm(request.POST)
#         if form.is_valid():
#             account = form.save()
#             account.is_active = False
#             account.save()
#             account.send_activation_email()
#             return render(request, 'accounts/registration.html', {'form': None})
#     else:
#         form = RegistrationForm()
#     return render(request, 'accounts/registration.html', {'form': form})
# 
# def activate_account(request, username, uid_hash):
#     if request.user.is_authenticated:
#         return HttpResponseRedirect(reverse('home'))
# 
#     try:
#         account = Account.objects.get(username__iexact=username)
#     except Account.DoesNotExist:
#         return render(request, 'accounts/activate.html', {'user_does_not_exist': True})
# 
#     new_hash = create_hash(account.id)
#     if new_hash != uid_hash:
#         return render(request, 'accounts/activate.html', {'decode_error': True})
# 
#     account.is_active = True
#     account.save()
#     return render(request, 'accounts/activate.html', {'all_ok': True})
# 
# def resend_activation_emmil(request):
#     if request.user.is_authenticated:
#         return HttpResponseRedirect(reverse('home'))
# 
#     if request.method == 'POST':
#         form = ReactivationForm(request.POST)
#         if form.is_valid():
#             account = form.cleaned_data['account']
#             account.send_activation_email()
#             return render(request, 'accounts/resend_activation.html', {'form': None})
#     else:
#         form = ReactivationForm()
#     return render(request, 'accounts/resend_activation.html', {'form': form})
# 
# Path: ac_mediator/views.py
# @login_required
# def monitor(request):
#     flower_auth = os.getenv('FLOWER_BASIC_AUTH', ':').split(':')
#     redmon_auth = os.getenv('FLOWER_BASIC_AUTH', ':').split(':')
#     return render(request, 'admin/monitor.html', {
#         'flower_auth': flower_auth,
#         'redmon_auth': redmon_auth,
#     })
# 
# @login_required
# @user_passes_test(lambda u: u.is_staff, login_url='/')
# def crash_me(request):
#     raise Exception('Everything is under control')


from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views as auth_views
from accounts.views import registration, activate_account, resend_activation_emmil
from ac_mediator.views import monitor, crash_me
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    url(r'^%sactivate/(?P<username>[^\/]+)/(?P<uid_hash>[^\/]+)/.*$' % domainPrefix, activate_account, name="accounts-activate"),
    url(r'^%sreactivate/$' % domainPrefix, resend_activation_emmil, name="accounts-resend-activation"),
    url(r'^%slogin/$' % domainPrefix, auth_views.login, {'template_name': 'accounts/login.html'}, name='login'),
    url(r'^%slogout/$' % domainPrefix, auth_views.logout, {'next_page': settings.LOGOUT_URL}, name='logout'),
    url(r'^%spassword_reset/$' % domainPrefix, auth_views.password_reset, dict(
            template_name='accounts/password_reset_form.html',
            subject_template_name='emails/password_reset_subject.txt',
            email_template_name='emails/password_reset.txt',
        ), name='password_reset'),
    url(r'^%spassword_reset/done/$' % domainPrefix, auth_views.password_reset_done, dict(
            template_name='accounts/password_reset_done.html'
        ), name='password_reset_done'),
    url(r'^%sreset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$' % domainPrefix,
        auth_views.password_reset_confirm, dict(
            template_name='accounts/password_reset_confirm.html'
        ), name='password_reset_confirm'),
    url(r'^%sreset/done/$' % domainPrefix, auth_views.password_reset_complete, dict(
            template_name='accounts/password_reset_complete.html'
        ), name='password_reset_complete'),

    # Accounts
    url(r'^%s' % domainPrefix, include('accounts.urls')),

    # Developers
    url(r'^developers/', include('developers.urls')),

    # Api
    url(r'^%sapi/' % domainPrefix, include('api.urls')),

    # Admin

# Path: accounts/views.py
# def registration(request):
#     if request.user.is_authenticated():
#         return HttpResponseRedirect(reverse('home'))
#     if request.method == 'POST':
#         form = RegistrationForm(request.POST)
#         if form.is_valid():
#             account = form.save()
#             account.is_active = False
#             account.save()
#             account.send_activation_email()
#             return render(request, 'accounts/registration.html', {'form': None})
#     else:
#         form = RegistrationForm()
#     return render(request, 'accounts/registration.html', {'form': form})
# 
# def activate_account(request, username, uid_hash):
#     if request.user.is_authenticated:
#         return HttpResponseRedirect(reverse('home'))
# 
#     try:
#         account = Account.objects.get(username__iexact=username)
#     except Account.DoesNotExist:
#         return render(request, 'accounts/activate.html', {'user_does_not_exist': True})
# 
#     new_hash = create_hash(account.id)
#     if new_hash != uid_hash:
#         return render(request, 'accounts/activate.html', {'decode_error': True})
# 
#     account.is_active = True
#     account.save()
#     return render(request, 'accounts/activate.html', {'all_ok': True})
# 
# def resend_activation_emmil(request):
#     if request.user.is_authenticated:
#         return HttpResponseRedirect(reverse('home'))
# 
#     if request.method == 'POST':
#         form = ReactivationForm(request.POST)
#         if form.is_valid():
#             account = form.cleaned_data['account']
#             account.send_activation_email()
#             return render(request, 'accounts/resend_activation.html', {'form': None})
#     else:
#         form = ReactivationForm()
#     return render(request, 'accounts/resend_activation.html', {'form': form})
# 
# Path: ac_mediator/views.py
# @login_required
# def monitor(request):
#     flower_auth = os.getenv('FLOWER_BASIC_AUTH', ':').split(':')
#     redmon_auth = os.getenv('FLOWER_BASIC_AUTH', ':').split(':')
#     return render(request, 'admin/monitor.html', {
#         'flower_auth': flower_auth,
#         'redmon_auth': redmon_auth,
#     })
# 
# @login_required
# @user_passes_test(lambda u: u.is_staff, login_url='/')
# def crash_me(request):
#     raise Exception('Everything is under control')


# Path: ac_mediator/urls.py
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views as auth_views
from accounts.views import registration, activate_account, resend_activation_emmil
from ac_mediator.views import monitor, crash_me
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    url(r'^%sactivate/(?P<username>[^\/]+)/(?P<uid_hash>[^\/]+)/.*$' % domainPrefix, activate_account, name="accounts-activate"),
    url(r'^%sreactivate/$' % domainPrefix, resend_activation_emmil, name="accounts-resend-activation"),
    url(r'^%slogin/$' % domainPrefix, auth_views.login, {'template_name': 'accounts/login.html'}, name='login'),
    url(r'^%slogout/$' % domainPrefix, auth_views.logout, {'next_page': settings.LOGOUT_URL}, name='logout'),
    url(r'^%spassword_reset/$' % domainPrefix, auth_views.password_reset, dict(
            template_name='accounts/password_reset_form.html',
            subject_template_name='emails/password_reset_subject.txt',
            email_template_name='emails/password_reset.txt',
        ), name='password_reset'),
    url(r'^%spassword_reset/done/$' % domainPrefix, auth_views.password_reset_done, dict(
            template_name='accounts/password_reset_done.html'
        ), name='password_reset_done'),
    url(r'^%sreset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$' % domainPrefix,
        auth_views.password_reset_confirm, dict(
            template_name='accounts/password_reset_confirm.html'
        ), name='password_reset_confirm'),
    url(r'^%sreset/done/$' % domainPrefix, auth_views.password_reset_complete, dict(
            template_name='accounts/password_reset_complete.html'
        ), name='password_reset_complete'),

    # Accounts
    url(r'^%s' % domainPrefix, include('accounts.urls')),

    # Developers
    url(r'^developers/', include('developers.urls')),

    # Api
    url(r'^%sapi/' % domainPrefix, include('api.urls')),

    # Admin

    url(r'^admin/monitor/$', monitor, name="admin-monitor"),