Skip to content

Commit

Permalink
fix: remove bad static file reference
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 15, 2021
1 parent 4aa1c88 commit fb78314
Show file tree
Hide file tree
Showing 8 changed files with 33,786 additions and 16 deletions.
30 changes: 30 additions & 0 deletions pepfar_mle/common/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
from django.core.exceptions import PermissionDenied
from model_bakery import baker

from pepfar_mle.common.views import HomeView

pytestmark = pytest.mark.django_db


def test_approved_mixin_approved_user(rf, django_user_model):
approved_user = baker.make(django_user_model, is_approved=True)
url = "/"
request = rf.get(url)
request.user = approved_user
view = HomeView()
view.setup(request)
view.dispatch(request) # no error raised


def test_approved_mixin_non_approved_authenticated_user(rf, django_user_model):
non_approved_user = baker.make(django_user_model, is_approved=False)
url = "/"
request = rf.get(url)
request.user = non_approved_user
view = HomeView()
view.setup(request)
with pytest.raises(PermissionDenied) as e:
view.dispatch(request) # no error raised

assert "PermissionDenied" in str(e)
15 changes: 11 additions & 4 deletions pepfar_mle/common/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.views.generic import TemplateView, View


class HomeView(LoginRequiredMixin, TemplateView):
class ApprovedMixin(UserPassesTestMixin, View):
permission_denied_message = "Your account is pending approval"

def test_func(self):
return self.request.user.is_authenticated and self.request.user.is_approved


class HomeView(LoginRequiredMixin, ApprovedMixin, TemplateView):
template_name = "pages/home.html"


class AboutView(LoginRequiredMixin, TemplateView):
class AboutView(LoginRequiredMixin, ApprovedMixin, TemplateView):
template_name = "pages/about.html"
6 changes: 3 additions & 3 deletions pepfar_mle/static/css/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -8664,16 +8664,16 @@ a.text-dark:hover, a.text-dark:focus {
color: #b94a48; }

.login-background-image {
background: url("../../static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover; }

.register-background-image {
background: url("../../static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover; }

.password-background-image {
background: url("../../static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover; }
33,734 changes: 33,733 additions & 1 deletion pepfar_mle/static/css/project.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pepfar_mle/static/css/sb-admin-2.css
Original file line number Diff line number Diff line change
Expand Up @@ -11229,7 +11229,7 @@ a:focus {
}

.bg-login-image {
background: url("static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover;
}
Expand Down
4 changes: 2 additions & 2 deletions pepfar_mle/static/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ $transition-collapse: height .15s ease !default;
$dropdown-font-size: 0.85rem !default;
$dropdown-border-color: $border-color !default;
// Images
$login-image: 'static/images/doc_keyboard.png' !default;
$register-image: 'https://source.unsplash.com/Mv9hjnEUHR4/600x800' !default;
$login-image: 'https://source.unsplash.com/NFvdKIhxYlU/600x800' !default;
$register-image: 'https://source.unsplash.com/NFvdKIhxYlU/600x800' !default;
$password-image: 'https://source.unsplash.com/oWTW-jNGl9I/600x800' !default;
6 changes: 3 additions & 3 deletions pepfar_mle/static/sass/project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ $red: #b94a48;
}

.login-background-image {
background: url("../../static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover;
}

.register-background-image {
background: url("../../static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover;
}

.password-background-image {
background: url("../../static/images/doc_keyboard.png");
background: url("https://source.unsplash.com/NFvdKIhxYlU/600x800");
background-position: center;
background-size: cover;
}
5 changes: 3 additions & 2 deletions pepfar_mle/utils/tests/test_storages.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import pytest
from django.core.management import call_command
from model_bakery import baker

pytestmark = pytest.mark.django_db


class TestStorages:
# def test_static_root_google_cloud_storage(self):
# call_command("collectstatic", "--noinput")
def test_static_root_google_cloud_storage(self):
call_command("collectstatic", "--noinput")

def test_media_root_google_cloud_storage(self):
org = baker.make("common.Organisation")
Expand Down

0 comments on commit fb78314

Please sign in to comment.