Free and open source ticket system written in python

๐Ÿ‘Œ IMPROVE: Refactor login view and template

+54 -13
+3 -1
core/views.py
··· 51 51 request.session.save() 52 52 53 53 if request.method == "POST": 54 - form = AuthenticationForm(data=request.POST) 54 + form = AuthenticationForm(request=request, data=request.POST) 55 55 if form.is_valid(): 56 + login(request, form.get_user()) 56 57 return redirect("home") 58 + 57 59 else: 58 60 form = AuthenticationForm() 59 61
+1 -1
paw/__init__.py
··· 1 1 from django import get_version 2 2 3 - VERSION = (0, 1, 0, "beta", 10) 3 + VERSION = (0, 1, 0, "beta", 11) 4 4 5 5 __version__ = get_version(VERSION)
+26 -11
paw/templates/core/login.html
··· 7 7 <div class="mb-4"> 8 8 {% include 'partials/logo.html' with responsive=False %} 9 9 </div> 10 - <h1 class="text-3xl font-bold p-2">Log In</h1> 10 + <div class="flex items-center"> 11 + <h1 class="text-3xl font-bold p-2">{% trans 'Log In' %}</h1> 12 + <div class="flex-grow"></div> 13 + <a href="{% url 'register' %}" class="btn btn-sm btn-neutral">{% trans 'Register Account' %}</a> 14 + </div> 11 15 <div class="bg-base-200 rounded p-8"> 12 16 <form method="post"> 13 17 {% csrf_token %} 18 + 19 + {% if form.non_field_errors %} 20 + <div role="alert" class="alert alert-error mb-4"> 21 + <svg xmlns="http://www.w3.org/2000/svg" class="hidden sm:block stroke-current shrink-0 h-6 w-6" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 10l4 4m0 -4l-4 4" /><path d="M12 3c7.2 0 9 1.8 9 9s-1.8 9 -9 9s-9 -1.8 -9 -9s1.8 -9 9 -9z" /></svg> 22 + <span>{{ form.non_field_errors }}</span> 23 + </div> 24 + {% endif %} 25 + 14 26 <div> 15 27 <label class="label"> 16 - <span class="text-base label-text" for="{{ form.username.id_for_label }}">Username</span> 28 + <span class="text-base label-text" for="{{ form.username.id_for_label }}">{% trans 'Username' %}</span> 17 29 </label> 18 30 <input type="text" name="username" placeholder="Username" class="w-full input input-bordered" /> 19 31 </div> 20 - <div> 21 - <label class="label"> 22 - <span class="text-base label-text" for="{{ form.password.id_for_label }}">Password</span> 23 - </label> 24 - <input type="password" name="password" placeholder="Enter Password" 32 + <label class="form-control w-full"> 33 + <div class="label"> 34 + <span class="text-base label-text" for="{{ form.password.id_for_label }}">{% trans 'Password' %}</span> 35 + </div> 36 + <input type="password" name="password" placeholder="Enter Password" 25 37 class="w-full input input-bordered" /> 26 - </div> 27 - <div class="flex justify-end mt-4"> 28 - <button type="submit" class="btn btn-accent">Log In</button> 38 + <div class="label"> 39 + <span class="label-text-alt"><a href="" class="link">{% trans 'Password Reset' %}</a></span> 40 + </div> 41 + </label> 42 + <div class="flex justify-end mt-2"> 43 + <button type="submit" class="btn btn-accent">{% trans 'Log In' %}</button> 29 44 </div> 30 45 </form> 31 46 {% if google_sso_enabled %} 32 47 <div class="divider"></div> 33 48 <a href="{{ google_sso_auth_url }}" class="btn w-full bg-[#4285F4] hover:bg-[#4285F4]/90 border-[#4285F4] text-white"> 34 49 <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2a9.96 9.96 0 0 1 6.29 2.226a1 1 0 0 1 .04 1.52l-1.51 1.362a1 1 0 0 1 -1.265 .06a6 6 0 1 0 2.103 6.836l.001 -.004h-3.66a1 1 0 0 1 -.992 -.883l-.007 -.117v-2a1 1 0 0 1 1 -1h6.945a1 1 0 0 1 .994 .89c.04 .367 .061 .737 .061 1.11c0 5.523 -4.477 10 -10 10s-10 -4.477 -10 -10s4.477 -10 10 -10z" stroke-width="0" fill="currentColor" /></svg> 35 - Log in with Google 50 + {% trans 'Log in with Google' %} 36 51 </a> 37 52 {% endif %} 38 53 </div>
+24
static/css/paw.css
··· 2056 2056 color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); 2057 2057 } 2058 2058 2059 + .label-text-alt { 2060 + font-size: 0.75rem; 2061 + line-height: 1rem; 2062 + --tw-text-opacity: 1; 2063 + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); 2064 + } 2065 + 2059 2066 .input input { 2060 2067 --tw-bg-opacity: 1; 2061 2068 background-color: var(--fallback-p,oklch(var(--p)/var(--tw-bg-opacity))); ··· 2120 2127 2121 2128 .join-item:focus { 2122 2129 isolation: isolate; 2130 + } 2131 + 2132 + @supports (color:color-mix(in oklab,black,black)) { 2133 + @media (hover:hover) { 2134 + .link-accent:hover { 2135 + color: color-mix(in oklab,var(--fallback-a,oklch(var(--a)/1)) 80%,black); 2136 + } 2137 + } 2138 + } 2139 + 2140 + .link-accent { 2141 + --tw-text-opacity: 1; 2142 + color: var(--fallback-a,oklch(var(--a)/var(--tw-text-opacity))); 2123 2143 } 2124 2144 2125 2145 .link:focus { ··· 2864 2884 2865 2885 .mt-8 { 2866 2886 margin-top: 2rem; 2887 + } 2888 + 2889 + .mt-2 { 2890 + margin-top: 0.5rem; 2867 2891 } 2868 2892 2869 2893 .block {