Browse Source

Django 1.10

pull/84/head
Pēteris Caune 8 years ago
parent
commit
965e32884b
13 changed files with 33 additions and 45 deletions
  1. +2
    -2
      hc/accounts/admin.py
  2. +0
    -13
      hc/accounts/management/commands/createprofiles.py
  3. +18
    -15
      hc/accounts/middleware.py
  4. +1
    -1
      hc/accounts/models.py
  5. +1
    -1
      hc/accounts/views.py
  6. +1
    -1
      hc/api/models.py
  7. +4
    -4
      hc/front/views.py
  8. +1
    -1
      hc/lib/badges.py
  9. +1
    -1
      hc/payments/context_processors.py
  10. +0
    -1
      hc/payments/models.py
  11. +1
    -1
      hc/payments/views.py
  12. +2
    -3
      hc/settings.py
  13. +1
    -1
      requirements.txt

+ 2
- 2
hc/accounts/admin.py View File

@ -1,8 +1,8 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from django.urls import reverse
from hc.accounts.models import Profile
from hc.api.models import Channel, Check
@ -12,7 +12,7 @@ class ProfileAdmin(admin.ModelAdmin):
class Media:
css = {
'all': ('css/admin/profiles.css',)
'all': ('css/admin/profiles.css',)
}
list_display = ("id", "users", "reports_allowed", "next_report_date",


+ 0
- 13
hc/accounts/management/commands/createprofiles.py View File

@ -1,13 +0,0 @@
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from hc.accounts.models import Profile
class Command(BaseCommand):
help = 'Make sure all users have profiles'
def handle(self, *args, **options):
for user in User.objects.all():
Profile.objects.get_or_create(user_id=user.id)
print("Done.")

+ 18
- 15
hc/accounts/middleware.py View File

@ -2,21 +2,24 @@ from hc.accounts.models import Profile
class TeamAccessMiddleware(object):
def process_request(self, request):
if not request.user.is_authenticated():
return
def __init__(self, get_response):
self.get_response = get_response
teams_q = Profile.objects.filter(member__user_id=request.user.id)
teams_q = teams_q.select_related("user")
request.teams = list(teams_q)
def __call__(self, request):
if request.user.is_authenticated:
teams_q = Profile.objects.filter(member__user_id=request.user.id)
teams_q = teams_q.select_related("user")
request.teams = list(teams_q)
try:
profile = request.user.profile
except Profile.DoesNotExist:
profile = Profile(user=request.user)
profile.save()
try:
profile = request.user.profile
except Profile.DoesNotExist:
profile = Profile(user=request.user)
profile.save()
if profile.current_team:
request.team = profile.current_team
else:
request.team = profile
if profile.current_team:
request.team = profile.current_team
else:
request.team = profile
return self.get_response(request)

+ 1
- 1
hc/accounts/models.py View File

@ -7,8 +7,8 @@ from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
from django.core import signing
from django.core.urlresolvers import reverse
from django.db import models
from django.urls import reverse
from django.utils import timezone
from hc.lib import emails


+ 1
- 1
hc/accounts/views.py View File

@ -101,7 +101,7 @@ def set_password_link_sent(request):
def check_token(request, username, token):
if request.user.is_authenticated() and request.user.username == username:
if request.user.is_authenticated and request.user.username == username:
# User is already logged in
return redirect("hc-checks")


+ 1
- 1
hc/api/models.py View File

@ -7,8 +7,8 @@ from datetime import timedelta as td
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db import models
from django.urls import reverse
from django.utils import timezone
from hc.api import transports
from hc.lib import emails


+ 4
- 4
hc/front/views.py View File

@ -6,10 +6,10 @@ import requests
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from django.db.models import Count
from django.http import HttpResponseBadRequest, HttpResponseForbidden, Http404
from django.http import Http404, HttpResponseBadRequest, HttpResponseForbidden
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.six.moves.urllib.parse import urlencode
@ -75,7 +75,7 @@ def _welcome_check(request):
def index(request):
if request.user.is_authenticated():
if request.user.is_authenticated:
return redirect("hc-checks")
check = _welcome_check(request)
@ -390,7 +390,7 @@ def add_pd(request):
def add_slack(request):
if not settings.SLACK_CLIENT_ID and not request.user.is_authenticated():
if not settings.SLACK_CLIENT_ID and not request.user.is_authenticated:
return redirect("hc-login")
ctx = {


+ 1
- 1
hc/lib/badges.py View File

@ -1,7 +1,7 @@
from django.conf import settings
from django.core.signing import base64_hmac
from django.template.loader import render_to_string
from django.core.urlresolvers import reverse
from django.urls import reverse
WIDTHS = {"a": 7, "b": 7, "c": 6, "d": 7, "e": 6, "f": 4, "g": 7, "h": 7,
"i": 3, "j": 3, "k": 7, "l": 3, "m": 10, "n": 7, "o": 7, "p": 7,


+ 1
- 1
hc/payments/context_processors.py View File

@ -4,7 +4,7 @@ from django.conf import settings
def payments(request):
show_pricing = settings.USE_PAYMENTS
if show_pricing and request.user.is_authenticated():
if show_pricing and request.user.is_authenticated:
profile = request.user.profile
if profile.current_team_id and profile.current_team_id != profile.id:
show_pricing = False


+ 0
- 1
hc/payments/models.py View File

@ -40,7 +40,6 @@ class Subscription(models.Model):
return self._pm
def pm_is_credit_card(self):
print(self.payment_method_token, self._get_braintree_payment_method())
return isinstance(self._get_braintree_payment_method(),
braintree.credit_card.CreditCard)


+ 1
- 1
hc/payments/views.py View File

@ -28,7 +28,7 @@ def get_client_token(request):
def pricing(request):
sub = None
if request.user.is_authenticated():
if request.user.is_authenticated:
# Don't use Subscription.objects.for_user method here, so a
# subscription object is not created just by viewing a page.
sub = Subscription.objects.filter(user_id=request.user.id).first()


+ 2
- 3
hc/settings.py View File

@ -40,15 +40,14 @@ INSTALLED_APPS = (
'hc.payments'
)
MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'hc.accounts.middleware.TeamAccessMiddleware',
)


+ 1
- 1
requirements.txt View File

@ -1,6 +1,6 @@
django-appconf==1.0.1
django-ses-backend==0.1.1
Django==1.9
Django==1.10
django_compressor==2.0
djmail==0.11.0
futures==3.0.3


Loading…
Cancel
Save