Skip to content

Commit

Permalink
change the login view and home page preview
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid75 committed Oct 22, 2019
1 parent 25b81a5 commit fcd72d4
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 25 deletions.
Binary file modified django-blog/chat/__pycache__/urls.cpython-37.pyc
Binary file not shown.
Binary file modified django-blog/chat/__pycache__/views.cpython-37.pyc
Binary file not shown.
74 changes: 63 additions & 11 deletions django-blog/chat/templates/chat/home.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
{% load static %}
{% load static %}
<title>HOME PAGE 😌</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="{% static 'chat/bootstrap.min.css' %}">
<!-- <link rel="stylesheet" href="{% static 'chat/codepen/style.css' %}"> -->

<!-- <link rel="stylesheet" href="{% static 'chat/bootstrap.min.css' %}"> -->
<!-- <script src="{% static 'chat/bootstrap.min.js' %}" type="javascript"></script> -->
<!-- <script src="{% static 'chat/jquery-3.3.1.min.js' %}" type="javascript"></script> -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'></script>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css'>

<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js'></script>



<!-- <script src="{% static 'chat/codepen/script.js' %}"></script> -->



<script>
$(document).ready(function(){
$('#myModal').modal('show');
});
</script>

<title>HOME PAGE 😌</title>

</head>


Expand All @@ -22,20 +34,56 @@






<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<!-- <button type="button" class="close" data-dismiss="modal">&times;</button> -->
<h4 class="modal-title">Welcome</h4>
</div>
<div class="modal-body">
<p>in this page you will see all posts you have ever created.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>








{%if user.is_authenticated %}
Hello {{user.username}}🐛


<a class="btn btn-outline-success mr-1 " style="float: right" href="{%url 'chat:logout' %}">LogOut</a>
<a class="btn btn-outline-success " href="{% url 'chat:create' %}">Create Post</a>
<a class="btn btn-outline-success" href="{% url "chat:password_change" %}">password reset</a>
<hr>
<hr><hr>






<p>in this page you will see the posts.</p>
<h1>Posts</h1>






<h3>Posts</h3>
{%for post in posts %}
<li><a href="{%url 'chat:details' pk=post.pk%}">{{post.title}}</a><br></li>
{%endfor%}
Expand All @@ -46,10 +94,14 @@ <h1>Posts</h1>
style="float: right"href="{%url 'chat:auth' %}">login</a>





<script src="{% static 'chat/codepen/script.js' %}"></script>
<script>
$(window).load(function(){
$('#myModal').modal('show');
});
</script>
<!-- <script src="{% static 'chat/codepen/script.js' %}"></script> -->

{%endif%}
</body>
Expand Down
13 changes: 4 additions & 9 deletions django-blog/chat/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@
path('update/<int:pk>',Postupdate.as_view(),name= 'postupdate'),
path('delete/<int:pk>',Postdelete.as_view(),name = 'deletepost'),

# path('accounts/',include('django.contrib.auth.urls')),
path('accounts/',include('django.contrib.auth.urls')),
# path('logout/',
# auth_views.LogoutView.as_view(next_page = reverse_lazy('chat:home')),name = 'logout'),



path("accounts/password_change",auth_views.PasswordChangeView.as_view(
success_url=reverse_lazy("chat:password_change_done")
),name="password_change"),

path("accounts/password_change",auth_views.PasswordChangeView.as_view(
success_url=reverse_lazy("chat:password_change_done")
),name="password_reset"),

),name="password_change"),

path('notfound/',someview),
path("register/",register,name="reg"),
path("login/",authenticating,name="auth"),
Expand Down
10 changes: 6 additions & 4 deletions django-blog/chat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate,login
from django.conf import settings
from django.contrib.auth.models import User



Expand Down Expand Up @@ -93,15 +94,15 @@

# ------------------------------------------------------------------#

class Postlist(LoginRequiredMixin,ListView):
class Postlist(ListView):

model = Post
template_name = 'chat/home.html'
context_object_name = 'posts'


def get_queryset(self):
username = self.request.user.username
username = self.request.user
return User.objects.get(username = username).post_set.all()


Expand Down Expand Up @@ -186,7 +187,8 @@ def register(request):
user = userinfoo.save(commit=False)
user.set_password(user.password)
user.save()
return HttpResponseRedirect(reverse("chat:home"))
# return HttpResponseRedirect(reverse("chat:auth"))
return authenticating(request)


else:
Expand Down Expand Up @@ -222,7 +224,7 @@ def authenticating(request):
return HttpResponse("there is no {} account on this website".format(username))


else:
else:
userinfoo = Userinfo()
context = {
"userinfoo":userinfoo,
Expand Down
Binary file modified django-blog/db.sqlite3
Binary file not shown.
Binary file modified django-blog/myblog/__pycache__/settings.cpython-37.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion django-blog/myblog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
STATIC_URL = '/chat/static/'



##LOGIN_REDIRECT_URL = "/chat/home"
Expand Down

0 comments on commit fcd72d4

Please sign in to comment.