diff --git a/account/forms.py b/account/forms.py index c78f9c79597d48fd0598e8f877c5b45c3cb21a6b..ca3eb22e23e233c003571911cb1d9457ea454f98 100644 --- a/account/forms.py +++ b/account/forms.py @@ -23,6 +23,10 @@ class RegisterFormAdmin(forms.Form): no_hp = forms.CharField(label='No HP', max_length=20, widget=forms.TextInput( attrs={'class': 'form-control', 'placeholder': 'No HP'})) + error_messages = { + 'required': 'This field is required', + } + class RegisterFormPelanggan(forms.Form): email = forms.EmailField(label='Email', max_length=50, widget=forms.TextInput( diff --git a/account/views.py b/account/views.py index 5ce9038d15781d4e56c3270d624b35b091ba9c20..77110cb8a9622e38a03c127d44e68c79fc3e50eb 100644 --- a/account/views.py +++ b/account/views.py @@ -728,10 +728,18 @@ def register_kurir(request): def dashboard_admin(request): + role = request.COOKIES.get('role') + if role != 'admin': + return HttpResponseRedirect(reverse('account:show_main')) + return render(request, 'dashboard_admin.html') def profile_restoran(request, email): + role = request.COOKIES.get('role') + if role != 'restaurant': + return HttpResponseRedirect(reverse('account:show_main')) + cursor.execute( f'select * from user_acc u, transaction_actor t, restaurant r where u.email = \'{email}\' and u.email = t.email and t.email = r.email') record = cursor.fetchall() @@ -755,6 +763,10 @@ def profile_restoran(request, email): def profile_pelanggan(request, email): + role = request.COOKIES.get('role') + if role != 'customer': + return HttpResponseRedirect(reverse('account:show_main')) + cursor.execute( f'select u.email, password, fname || \' \' || lname as name, phonenum, nik, bankname, accountno, birthdate, sex, restopay, adminid from user_acc u, transaction_actor t, customer c where u.email = \'{email}\' and u.email = t.email and t.email = c.email') record = cursor.fetchall() @@ -766,6 +778,10 @@ def profile_pelanggan(request, email): def profile_kurir(request, email): + role = request.COOKIES.get('role') + if role != 'courier': + return HttpResponseRedirect(reverse('account:show_main')) + cursor.execute( f'select * from user_acc u, transaction_actor t, courier c where u.email = \'{email}\' and u.email = t.email and t.email = c.email') record = cursor.fetchall() diff --git a/templates/navbar.html b/templates/navbar.html index db4fc9f27c75b93273d6b696d02e3efc253c0cfc..6a75f86e8b9f59d210a23ea05546baab66c0fdb6 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -63,6 +63,7 @@ </div> </div> </div> + <!-- {admin start} --> {% if role == 'admin' %} <div @click.away="open = false" class="relative" x-data="{ open: false }"> @@ -237,12 +238,7 @@ </div> {% endif %} <!-- admin end --> - - <!-- pelanggan start --> - {% if role == 'customer' and adminid != None %} - <div class="md:mx-5 my-3 md:my-0 text-center"> - <a href="{% url 'trigger3:daftar_restoran' %}" class="hover:text-[#DBC8AC] hover:text-lg duration-500 whitespace-nowrap">Daftar Restoran dan Makanan</a> - </div> + <!-- pelanggan start --> {% if role == 'customer' and adminid != None %} <div class="md:mx-5 my-3 md:my-0 text-center"> @@ -369,4 +365,4 @@ <a href="{% url 'account:logout' %}" class="hover:text-[#DBC8AC] hover:text-lg duration-500">Logout</a> </div> </div> -</nav> +</nav> \ No newline at end of file diff --git a/trigger_2/forms.py b/trigger_2/forms.py index 95dd289b1a9a5f06d369bccf43274dc7f9d36221..cf582af72a95ad8448424325e0edca2dc134b077 100644 --- a/trigger_2/forms.py +++ b/trigger_2/forms.py @@ -28,6 +28,8 @@ class FormBuatJamOperasional(forms.Form): attrs={'class': 'w-[20rem] h-[2.5rem] rounded-lg border-2 border-gray-300', 'type': 'time'})) + + class FormEditJamOperasional(forms.Form): # Jam buka time picker jam_buka = forms.TimeField(label='Jam Buka', widget=forms.TimeInput(