-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
from django.conf import settings | ||
from django.conf.urls import patterns, include, url | ||
from django.views.generic import TemplateView | ||
from views import index, status, profile, my_profile | ||
from views import IndexView, StatusView, ProfileView, MyProfileView | ||
|
||
# Uncomment the next two lines to enable the admin: | ||
from django.contrib import admin | ||
admin.autodiscover() | ||
|
||
urlpatterns = patterns( | ||
'', | ||
url(r'^$', index), | ||
url(r'^status$', status), | ||
url(r'^$', IndexView.as_view(), name='index'), | ||
url(r'^status$', StatusView.as_view(), name='status'), | ||
url(r'^(favicon\.ico)$', 'django.views.static.serve', | ||
{'document_root': settings.STATIC_ROOT}), | ||
url(r'^admin/', include(admin.site.urls)), | ||
|
||
url(r'^zen/$', 'zen.views.index', name='zen'), | ||
url(r'^zen/', include('zen.urls'), name='zen'), | ||
(r'^accounts/', include('registration.backends.simple.urls')), | ||
url(r'^accounts/profile/$', my_profile, name="me"), | ||
url(r'^users/(?P<username>.*)/$', profile, name='profile'), | ||
url(r'^accounts/profile/$', MyProfileView.as_view(), name="me"), | ||
url(r'^users/(?P<username>.*)/$', ProfileView.as_view(), name='profile'), | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import random | ||
from django.conf import settings | ||
from emergent.base import render | ||
from django.contrib.auth.decorators import login_required | ||
from django.contrib.auth import get_user_model | ||
from django.views.generic import TemplateView | ||
from braces.views import LoginRequiredMixin | ||
|
||
|
||
__all__ = ( | ||
'index', | ||
'status', | ||
'IndexView', | ||
'StatusView', | ||
'ProfileView', | ||
'MyProfileView', | ||
) | ||
|
||
|
||
@render("emergent/index") | ||
def index(request): | ||
import random | ||
price = random.randint(0, 99) | ||
return {"price": price} | ||
class IndexView(TemplateView): | ||
template_name = 'emergent/index.html' | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(IndexView, self).get_context_data(**kwargs) | ||
context["price"] = random.randint(0, 99) | ||
return context | ||
|
||
@login_required | ||
@render("emergent/status") | ||
def status(request): | ||
with open(os.path.join(settings.PROJECT_PATH, "status.txt")) as f: | ||
status = f.read() | ||
return {"status": status} | ||
|
||
class StatusView(LoginRequiredMixin, TemplateView): | ||
template_name = 'emergent/status.html' | ||
|
||
@login_required | ||
@render("emergent/profile") | ||
def profile(request, username): | ||
profile = get_user_model().objects.get(username=username) | ||
return {"profile": profile} | ||
def get_context_data(self, **kwargs): | ||
context = super(StatusView, self).get_context_data(**kwargs) | ||
with open(os.path.join(settings.PROJECT_PATH, "status.txt")) as f: | ||
context['status'] = f.read() | ||
return context | ||
|
||
|
||
@login_required | ||
@render("emergent/profile") | ||
def my_profile(request): | ||
return {"profile": request.user} | ||
class ProfileView(LoginRequiredMixin, TemplateView): | ||
template_name = 'emergent/profile.html' | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(ProfileView, self).get_context_data(**kwargs) | ||
context['profile'] = get_user_model().objects.get(username=kwargs['username']) | ||
return context | ||
|
||
|
||
class MyProfileView(LoginRequiredMixin, TemplateView): | ||
template_name = 'emergent/profile.html' | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(MyProfileView, self).get_context_data(**kwargs) | ||
context['profile'] = self.request.user | ||
return context | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ flup | |
django-registration | ||
django-bower | ||
django-setuptest | ||
django-braces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# coding: utf8 | ||
|
||
from django.conf.urls import patterns, url | ||
from views import IndexView | ||
|
||
urlpatterns = patterns('', | ||
url(r'^$', IndexView.as_view(), name='zen-index'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters