이경수

add user edit page

......@@ -11,6 +11,14 @@ class UserCreationForm(UserCreationForm):
help_text=("github 레포지토리를 등록하세요."))
class UserEditForm(forms.Form):
email = EmailField(label=("이메일"), required=True,
help_text=("이메일을 입력하세요."))
repository = URLField(label=("레포지토리"), required=True,
help_text=("github 레포지토리를 입력하세요."))
class Meta:
model = User
fields = ("username", "email", "repository", "password1", "password2")
......
......@@ -26,6 +26,8 @@ urlpatterns = [
url(r'^home/', HomeView.as_view(), name='home'),
url(r'^myapp/', include('myapp.urls', namespace='myapp')),
url(r'^edit/', EditView.as_view(), name='edit'),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^accounts/register/$', UserCreateView.as_view(), name='register'),
url(r'^accounts/register/done$', UserCreateDoneTV.as_view(), name='register_done'),
......
......@@ -59,6 +59,25 @@ class HomeView(View):
# with connection.cursor() as cursor:
# cursor.execute(query, param_list)
class EditView(TemplateView):
template_name = 'registration/edit.html'
success_url = reverse_lazy('register_done')
def get(self, request, *args, **kwargs):
context = {}
red = 10
context['red'] = red
context['form'] = UserEditForm
return render(self.request, self.template_name, context)
def post(self, request, *args, **kwargs):
email = self.request.POST['email']
repository = self.request.POST['repository']
print(email, repository)
return render(self.request, 'index.html')
class UserCreateView(CreateView):
......
This diff is collapsed. Click to expand it.
......@@ -14,6 +14,31 @@ class MypageView(TemplateView):
context = {}
context['form'] = testform
query = 'SELECT * FROM vuln.vulnInfo'
param_list = []
with connection.cursor() as cursor:
cursor.execute(query, param_list)
columns = [column[0] for column in cursor.description]
object_list = []
for row in cursor.fetchall():
object_list.append(dict(zip(columns, row)))
context = {}
red = 3
blue = 4
green = 5
context['red'] = red
context['blue'] = blue
context['green'] = green
context['object_list'] = object_list
return render(self.request, self.template_name, context)
......
......@@ -37,10 +37,6 @@
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#about">Dynamic</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#contact">Contact</a>
</li>
{% if user.is_active %}
<!-- <li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/mypage">myPage</a>
......@@ -49,7 +45,7 @@
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="{% url 'logout' %}?next=/home">Logout</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="{% url 'logout' %}?next=/home">Edit Info</a>
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="{% url 'edit' %}">Edit Info</a>
</li>
{% else %}
<li class="nav-item mx-0 mx-lg-1">
......@@ -214,34 +210,7 @@
<br></p>
</div>
<div class="col-md-4 mb-5 mb-lg-0">
<h4 class="text-uppercase mb-4">Around the Web</h4>
<ul class="list-inline mb-0">
<li class="list-inline-item">
<a class="btn btn-outline-light btn-social text-center rounded-circle" href="#">
<i class="fa fa-fw fa-facebook"></i>
</a>
</li>
<li class="list-inline-item">
<a class="btn btn-outline-light btn-social text-center rounded-circle" href="#">
<i class="fa fa-fw fa-google-plus"></i>
</a>
</li>
<li class="list-inline-item">
<a class="btn btn-outline-light btn-social text-center rounded-circle" href="#">
<i class="fa fa-fw fa-twitter"></i>
</a>
</li>
<li class="list-inline-item">
<a class="btn btn-outline-light btn-social text-center rounded-circle" href="#">
<i class="fa fa-fw fa-linkedin"></i>
</a>
</li>
<li class="list-inline-item">
<a class="btn btn-outline-light btn-social text-center rounded-circle" href="#">
<i class="fa fa-fw fa-dribbble"></i>
</a>
</li>
</ul>
</div>
<div class="col-md-4">
<h4 class="text-uppercase mb-4">About Us</h4>
......
{% load staticfiles %}
{% load crispy_forms_tags %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>VulnNotti</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="{% static 'vendor/freelancer_bootstrap/css/bootstrap.min.css' %}">
<!-- Custom fonts for this template -->
<link rel="stylesheet" href="{% static 'vendor/freelancer_font-awesome/css/font-awesome.min.css' %}">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- Plugin CSS -->
<link rel="stylesheet" href="{% static 'vendor/magnific-popup/magnific-popup.css' %}">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="{% static 'css/freelancer.min.css' %}">
<style>
.errornote{
display: block;
margin: 5px 0;
border: 1px solid #c30;
background: #fcf;
padding: 5px 25px;
color: #c30;
font-size: 12px;
font-weight: bold;
}
fieldset{
border: 1px solid #ccc;
}
.aligned label{
width: 170px;
display: block;
padding: 3px 10px 0 0;
float: left;
}
.form-row{
padding: 10px;
font-size: 11px;
border-bottom: 1px solid #eee;
}
.submit-row{
margin: 5px 0;
border: 1px solid #ccc;
text-align: right;
}
.submit-row input{
margin: 10px;
background: #ffc;
}
</style>
</head>
<body id="page-top">
<!-- Header -->
<header class="masthead bg-primary text-white text-center">
<div class="container">
<h1>Edit User Repository</h1>
</div>
</header>
<section>
<form method="post" action="."> {% csrf_token %}
{% if form.errors %}
<p class="errornote">Wrong! Please correct the error(s) below.</p>
{% endif %}
<fieldset class="aligned">
<div>
{{ form|crispy }}
</div>
<input class="btn btn-success" style="background-color:#FF0066; border:#FF0066;"type="submit" value="Edit"/>
</fieldset>
</section>
<div class="copyright py-4 text-center text-white">
<div class="container">
<small>Copyright &copy;www.VulnNotti.com</small>
</div>
</div>
<!-- Scroll to Top Button (Only visible on small and extra-small screen sizes) -->
<div class="scroll-to-top d-lg-none position-fixed ">
<a class="js-scroll-trigger d-block text-center text-white rounded" href="#page-top">
<i class="fa fa-chevron-up"></i>
</a>
</div>
<!-- Portfolio Modals -->
<script src="{% static 'vendor/freelancer_jquery/jquery.min.js' %}"></script>
<script src="{% static 'vendor/freelancer_bootstrap/js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static 'vendor/jquery-easing/jquery.easing.min.js' %}"></script>
<script src="{% static 'vendor/magnific-popup/jquery.magnific-popup.min.js' %}"></script>
<script src="{% static 'js/jqBootstrapValidation.js' %}"></script>
<script src="{% static 'js/contact_me.js' %}"></script>
<script src="{% static 'js/freelancer.min.js' %}"></script>
</body>
</html>