Skip to content
Snippets Groups Projects
Commit 6fdbb54c authored by Brody Wilton's avatar Brody Wilton
Browse files

restrict dashboard based on user type

parent 2c45a9f2
Branches
No related tags found
1 merge request!30restrict dashboard based on user type
......@@ -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>
......
......@@ -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>
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment