Skip to content

Commit 8d84442

Browse files
sh dashboard
1 parent ca67125 commit 8d84442

107 files changed

Lines changed: 135 additions & 130485 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,5 @@ shopyo/static/modules/
126126

127127
# ignore secrets
128128
config.json
129+
130+
exp/

pythoncms/config_demo.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"APP_NAME": "Demo",
88
"ACTIVE_FRONT_THEME": "editorial",
99
"ACTIVE_BACK_THEME": "sneat",
10-
"ACTIVE_ICONSET": "fa",
1110
"SITE_TITLE": "My site",
1211
"SITE_DESCRIPTION": "description",
1312
"CURRENCY": "MUR",

pythoncms/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def db(test_client, non_admin_user, admin_user, unconfirmed_user):
102102
_db.app = test_client
103103
_db.create_all()
104104

105-
# Insert admin, non admin, and unconfirmed
106-
_db.session.add(non_admin_user)
107-
_db.session.add(admin_user)
108-
_db.session.add(unconfirmed_user)
105+
# Insert admin, non admin, and unconfirmed if they don't exist
106+
for u in [non_admin_user, admin_user, unconfirmed_user]:
107+
if not User.query.filter_by(email=u.email).first():
108+
_db.session.add(u)
109109

110110
# add the default settings
111111
with open("config.json") as config:
@@ -118,7 +118,7 @@ def db(test_client, non_admin_user, admin_user, unconfirmed_user):
118118
else:
119119
existing.value = value
120120

121-
# Commit the changes for the users
121+
# Commit the changes
122122
_db.session.commit()
123123

124124
yield _db # this is where the testing happens!
@@ -221,13 +221,13 @@ def __init__(self, client):
221221

222222
def login(self, user, password="pass"):
223223
return self._client.post(
224-
url_for("auth.login"),
224+
url_for("shopyo_auth.login"),
225225
data=dict(email=user.email, password=password),
226226
follow_redirects=True,
227227
)
228228

229229
def logout(self):
230-
return self._client.get(url_for("auth.logout"), follow_redirects=True)
230+
return self._client.get(url_for("shopyo_auth.logout"), follow_redirects=True)
231231

232232

233233
# Want TO USE THE BELOW 2 FIXTURES TO DYNAMICALLY

pythoncms/modules/api/info.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"display_string": "API",
33
"type": "show",
4-
"icons": {
5-
"fa": "fas fa-network-wired",
6-
"boxicons": "bx bx-network-chart"
7-
},
4+
"fa-icon": "fas fa-network-wired",
85
"url_prefix": "/api/v1",
96
"menu-type": "no-menu",
107
"module_name": "api",

pythoncms/modules/api/tests/__init__.py

Whitespace-only changes.

pythoncms/modules/contact/info.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"display_string": "Contact",
33
"type": "show",
4-
"icons":{
5-
"fa": "fa fa-envelope",
6-
"boxicons": "bx bx-envelope"
7-
},
4+
"fa-icon": "fa fa-envelope",
85
"url_prefix": "/contact",
96
"dashboard": "/dashboard",
107
"author": {

pythoncms/modules/contact/templates/contact/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{%extends get_active_back_theme()+'/base.html'%}
1+
{% extends 'shopyo_dashboard/dashboard_base.html' %}
22

33

44
{%block content%}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pytest
2+
from init import db
3+
from modules.contact.models import ContactMessage
4+
from flask import url_for
5+
6+
def test_contact_index(test_client):
7+
response = test_client.get("/contact/")
8+
assert response.status_code == 200
9+
assert b"Contact" in response.data
10+
11+
def test_contact_submit_fail_no_auth(test_client):
12+
# validate_message requires login_required in view.py
13+
response = test_client.post("/contact/validate_message", data={
14+
"name": "Test",
15+
"email": "test@test.com",
16+
"message": "Hello"
17+
}, follow_redirects=True)
18+
# Redirects to login
19+
assert b"Login" in response.data
20+
21+
def test_contact_dashboard_no_auth(test_client):
22+
response = test_client.get("/contact/dashboard", follow_redirects=True)
23+
assert b"Login" in response.data
24+
25+
def test_contact_submit_and_dashboard(test_client, login_admin_user):
26+
# Now logged in as admin (from conftest.py login_admin_user fixture)
27+
response = test_client.post("/contact/validate_message", data={
28+
"name": "Test User",
29+
"email": "testuser@test.com",
30+
"message": "This is a test message"
31+
}, follow_redirects=True)
32+
33+
# Check if message is in DB
34+
msg = ContactMessage.query.filter_by(email="testuser@test.com").first()
35+
assert msg is not None
36+
assert msg.name == "Test User"
37+
38+
# Check dashboard
39+
response = test_client.get("/contact/dashboard")
40+
assert response.status_code == 200
41+
assert b"Test User" in response.data
42+
assert b"This is a test message" in response.data

pythoncms/modules/contenttype/templates/contenttype/create.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends get_active_back_theme()+'/base.html' %}
1+
{% extends 'shopyo_dashboard/dashboard_base.html' %}
22

33
{% block content %}
44
<div class="container-xxl flex-grow-1 container-p-y">

pythoncms/modules/contenttype/templates/contenttype/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends get_active_back_theme()+'/base.html' %}
1+
{% extends 'shopyo_dashboard/dashboard_base.html' %}
22

33
{% block content %}
44
<div class="container-xxl flex-grow-1 container-p-y">

0 commit comments

Comments
 (0)