신은섭(Shin Eun Seop)

add login, logout, signup, delete account, file listing, file upload(partial)

closed kairos03/2018-1-d.cloud#4
closed kairos03/2018-1-d.cloud#5
closed kairos03/2018-1-d.cloud#6
closed kairos03/2018-1-d.cloud#7
closed kairos03/2018-1-d.cloud#10
kairos03/2018-1-d.cloud#8
......@@ -4,9 +4,11 @@ from django.contrib.auth import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/login/$', views.login, name='login'),
url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page': '/'}),
url(r'^restapi/', include('restful.urls')),
url(r'^', include('website.urls')),
url(r'^accounts/login/$', views.login, name='login'),
url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page': '/'}),
]
......
from django.contrib import admin
from website.models import Post
# from website.models import Post
admin.site.register(Post)
\ No newline at end of file
# admin.site.register(Post)
\ No newline at end of file
......
from django.contrib.auth import login, authenticate
from django.contrib.auth import login, authenticate, logout
from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
......@@ -32,5 +32,6 @@ def delete_account(request):
def delete_account_success(request):
if request.method == 'GET':
# TODO Add delete account
logout(request)
return render(request, 'registration/delete_account_success.html')
......
from django import forms
from website.models import Post
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title', 'text')
\ No newline at end of file
# class PostForm(forms.ModelForm):
# class Meta:
# model = Post
# fields = ('title', 'text')
\ No newline at end of file
......
{% load staticfiles %}
<html>
<head>
<title>Django Girls blog</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link href="//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{% static 'css/posts.css' %}">
</head>
<body>
<div class="page-header">
{% if user.is_authenticated %}
<a href="{% url 'post_new' %}" class="top-menu"><span class="glyphicon glyphicon-plus"></span></a>
<a href="{% url 'post_draft_list' %}" class="top-menu"><span class="glyphicon glyphicon-edit"></span></a>
<p class="top-menu">Hello {{ user.username }} <small>(<a href="{% url 'logout' %}">Log out</a>)</small></p>
{% else %}
<a href="{% url 'login' %}" class="top-menu"><span class="glyphicon glyphicon-lock"></span></a>
{% endif %}
<h1><a href="/">Django Girls Blog</a></h1>
</div>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -7,7 +7,7 @@
{% if user.is_authenticated %}
<p class="top-menu">Hello {{ user.username }} <small>(<a href="{% url 'logout' %}">Log out</a>)</small></p>
{% else %}
<a href="{% url 'login' %}" class="top-menu"><span class="glyphicon glyphicon-lock"></span></a>
<a href="{% url 'login' %}" class="top-menu">Log in<span class="glyphicon glyphicon-lock"></span></a>
{% endif %}
<h1><a href="/">D.cloud</a></h1>
</div>
......
......@@ -2,7 +2,7 @@
{% block content %}
{% for file in files %}
<h1>{{file.title}}</h1>
<p>{{file.object_key}}</p>
<h1>{{file.name}}</h1>
<p>{{file.type}}</p>
{% endfor %}
{% endblock %}
\ No newline at end of file
......
{% extends 'website/baseline.html' %}
{% block content %}
<h1> Hello </h1>
{% endblock %}
\ No newline at end of file
{% extends 'website/base.html' %}
{% block content %}
<div class="post">
{% if post.published_date %}
<div class="date">
{{ post.published_date }}
</div>
{% else %}
<a class="btn btn-default" href="{% url 'post_publish' pk=post.pk %}">Publish</a>
{% endif %}
{% if user.is_authenticated %}
<a class="btn btn-default" href="{% url 'post_edit' pk=post.pk %}"><span class="glyphicon glyphicon-pencil"></span></a>
{% endif %}
<h1>{{ post.title }}</h1>
<p>{{ post.text|linebreaksbr }}</p>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'website/base.html' %}
{% block content %}
{% for post in posts %}
<div class="post">
<p class="date">created: {{ post.created_date|date:'d-m-Y' }}</p>
<h1><a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a></h1>
<p>{{ post.text|truncatechars:200 }}</p>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends 'website/base.html' %}
{% block content %}
<h1>New post</h1>
<form method="POST" class="post-form">{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="save btn btn-default">Save</button>
</form>
{% endblock %}
\ No newline at end of file
{% extends 'website/base.html' %}
{% block content %}
{% for post in posts %}
<div class="post">
<div class="date">
<p>published: {{ post.published_date }}</p>
</div>
<h1>
<h1><a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a></h1>
</h1>
<p>{{ post.text|linebreaksbr }}</p>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.conf.urls import url
from website import views, auth_views
from django.shortcuts import redirect
from website import views, auth_views
urlpatterns = [
# blog
url(r'^$', redirect('login')),
url(r'^files/', views.file_list, name='file_list'),
url(r'^accounts/signup/$', auth_views.signup, name='signup'),
url(r'^accounts/delete_account/$', auth_views.delete_account, name='delete_account'),
url(r'^accounts/delete_account_success/$', auth_views.delete_account_success, name='delete_account_success'),
# blog
url(r'^$', views.home),
url(r'^files/', views.file_list, name='file_list'),
]
\ No newline at end of file
......
from django.shortcuts import render, get_object_or_404, redirect
from django.shortcuts import render, get_object_or_404, redirect, Http404
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from website.models import Post
from restful.models import File
from website.forms import PostForm
import requests
def home(request):
return render(request, 'website/home.html')
@login_required
def file_list(request):
files = File.objects.all()
return render(request, 'website/file_list.html', {'files': files})
files = requests.get('http://localhost:8000/restapi/files')
files = files.json()
return render(request, 'website/file_list.html', files)
......