Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
desd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kj2-drupisz
desd
Commits
6fdbb54c
Commit
6fdbb54c
authored
1 year ago
by
Brody Wilton
Browse files
Options
Downloads
Patches
Plain Diff
restrict dashboard based on user type
parent
2c45a9f2
Branches
Branches containing commit
No related tags found
1 merge request
!30
restrict dashboard based on user type
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
myproject/myapp/templates/pricing.html
+1
-1
1 addition, 1 deletion
myproject/myapp/templates/pricing.html
myproject/myapp/templates/user_page.html
+13
-5
13 additions, 5 deletions
myproject/myapp/templates/user_page.html
myproject/myapp/views.py
+4
-0
4 additions, 0 deletions
myproject/myapp/views.py
with
18 additions
and
6 deletions
myproject/myapp/templates/pricing.html
+
1
−
1
View file @
6fdbb54c
...
...
@@ -42,7 +42,7 @@
</div>
<div
class=
"w-full mx-auto max-w-sm p-4 bg-white border border-gray-200 rounded-lg shadow sm:p-8 dark:bg-gray-800 dark:border-gray-700"
>
<h5
class=
"mb-4 text-xl font-medium text-gray-500 dark:text-gray-400"
>
Standard plan
</h5>
<h5
class=
"mb-4 text-xl font-medium text-gray-500 dark:text-gray-400"
>
Bulk Purchase
</h5>
<div
class=
"flex items-baseline text-gray-900 dark:text-white"
>
<span
class=
"text-3xl font-semibold"
>
£
</span>
<span
class=
"text-5xl font-extrabold tracking-tight"
>
49
</span>
...
...
This diff is collapsed.
Click to expand it.
myproject/myapp/templates/user_page.html
+
13
−
5
View file @
6fdbb54c
...
...
@@ -6,8 +6,12 @@
<h1
class=
"mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white"
>
User settings
</h1>
<h3
class=
"mb-4 text-xl font-semibold dark:text-white"
>
User type: {{ user_profile.user_type }}
</h3>
</div>
<!-- Right Content -->
<div
class=
"col-span-full xl:col-auto"
>
<div
class=
"p-4 mb-4 bg-white border boder-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
<h3
class=
"mb-4 text-xl font-semibold dark:text-white"
>
Tokens:
</h3>
...
...
@@ -18,10 +22,12 @@
<a
href=
"{% url 'password_change' %}"
class=
"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
Change Password
</a>
</div>
{% if 1 %}
{% if user_profile.user_type == 3 %}
<div
class=
"p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
<h3
class=
"mb-4 text-xl font-semibold dark:text-white"
>
Generate Financial Statement
</h3>
...
...
@@ -69,7 +75,8 @@
</form>
{% comment %} REPLACE WITH LOGIC TO CHECK PROPER USER {% endcomment %}
</div>
{% endif %} {% if 1 %}
{% endif %}
{% if 1 %}
<div
class=
"p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
...
...
@@ -130,7 +137,7 @@
class=
"shadow-sm bg-gray-50 border border-gray-300 text-grey-300 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder=
"example@gmail.com"
required
>
example@gmail.com
</span
>
{{ user.email }}
</span
>
</div>
<div
class=
"col-span-6 sm:col-span-3"
>
...
...
@@ -146,7 +153,7 @@
class=
"shadow-sm bg-gray-50 border border-gray-300 text-grey-300 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder=
"Green"
required
>
LoginExample
</span
>
{{ user.username }}
</span
>
</div>
</div>
...
...
@@ -193,7 +200,7 @@
</div>
{% if 1 %} {% comment %} REPLACE WITH LOGIC TO CHECK PROPER USER
{%endcomment %}
{% if user_profile.user_type == 2 %}
<div
class=
"p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
...
...
@@ -238,6 +245,7 @@
</tbody>
</table>
</div>
{% endif %}
{% endif %} {% comment %} Admin page functionality end {% endcomment %}
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
myproject/myapp/views.py
+
4
−
0
View file @
6fdbb54c
...
...
@@ -153,11 +153,15 @@ def users(request):
admin_dict
=
json
.
loads
(
data_admin
.
content
)
user_dict
=
json
.
loads
(
data_user
.
content
)
token_count
=
UserTokenCount
.
objects
.
get
(
user
=
request
.
user
).
token_count
user_profile
=
request
.
user
.
profile
user
=
request
.
user
# Pass the data as a context variable to the template
# !!! ADMIN DATA ONLY DISPLAYED AND GET IF USER IS ADMIN !!!
context
[
'
admin_data
'
]
=
admin_dict
[
'
data
'
]
context
[
'
user_data
'
]
=
user_dict
[
'
data
'
]
context
[
'
token_count
'
]
=
token_count
context
[
'
user_profile
'
]
=
user_profile
context
[
'
user
'
]
=
user
return
render
(
request
,
'
user_page.html
'
,
context
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment