Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions neuropy/neuropy/static/neuropy/sticky-footer-navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ code {
overflow: auto;
margin-bottom: 30px;
}

.unstyled {
list-style: none;
}
2 changes: 0 additions & 2 deletions neuropy/neuropy/templates/neuropy/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
{% endblock stylesheets %}
</head>
<body>
<nav>
</nav>

{% block body %}
{% endblock body %}
Expand Down
17 changes: 15 additions & 2 deletions neuropy/userprofile/templates/userprofile/edit_profile.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{% extends 'neuropy/layout.html' %}
{% block content %}
<form action="" method="post">{% csrf_token %}

<div class="row">
<div class='page-header'>
<div class='btn-toolbar pull-right'>
<div class='btn-group'>
<a href="{% url 'profile' %}" class="btn">Profile</a>
</div>
</div>
<h1>Edit your profile</h1>
</div>
</div>
<div>
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update" />
<input class="btn btn-primary" type="submit" value="Update" />
</form>
</div>
{% endblock %}
27 changes: 18 additions & 9 deletions neuropy/userprofile/templates/userprofile/profile.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{% extends 'neuropy/layout.html' %}
{% block content %}
<h2>Welcome {{user.username}}!</h2>
<ul>
<li>Name: {{user.first_name|title}} {{user.last_name|title}}</li>
<li>Email: <a href="mailto:{{user.email}}">{{user.email}}</a></li>
<li>Active Period Start: {{ user.profile.active_period_start }}</li>
<li>Active Period End: {{ user.profile.active_period_end }}</li>
<li>Peak Period: {{ user.profile.peak_period }}</li>
<li>Dose Time: {{ user.profile.dose_time }}</li>

<div class="row">
<div class='page-header'>
<div class='btn-toolbar pull-right'>
<div class='btn-group'>
<a href="{% url 'edit-profile' %}" class="btn">Edit Profile</a>
</div>
</div>
<h1>Welcome {{user.username}}!</h1>
</div>
</div>
<ul class="unstyled">
<li><strong>Name: </strong>{{user.first_name|title}} {{user.last_name|title}}</li>
<li><strong>Email: </strong><a href="mailto:{{user.email}}">{{user.email}}</a></li>
<li><strong>Active Period Start: </strong>{{ user.profile.active_period_start }}</li>
<li><strong>Active Period End: </strong>{{ user.profile.active_period_end }}</li>
<li><strong>Peak Period: </strong>{{ user.profile.peak_period }}</li>
<li><strong>Dose Time: </strong>{{ user.profile.dose_time }}</li>
</ul>
<a href="{% url 'edit-profile' %}"><button type="button">Edit Profile</button></a>
{% endblock %}
5 changes: 2 additions & 3 deletions neuropy/userprofile/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Profile urls."""
from django.conf.urls import url
from .views import ProfileView, EditProfile
from django.contrib.auth.decorators import login_required

urlpatterns = [
url(r'^edit/$', login_required(EditProfile.as_view()), name='edit-profile'),
url(r'^$', login_required(ProfileView.as_view()), name='profile')
url(r'^edit/$', EditProfile.as_view(), name='edit-profile'),
url(r'^$', ProfileView.as_view(), name='profile')
]
19 changes: 12 additions & 7 deletions neuropy/userprofile/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
"""Views for profile."""
from django.views.generic import detail, UpdateView
from userprofile.models import Profile

from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
from django.urls import reverse_lazy
from django.views.generic import DetailView, UpdateView

from userprofile.forms import ProfileForm
from django.http import HttpResponseRedirect
from userprofile.models import Profile


class ProfileView(detail.DetailView):
"""View for profle."""
class ProfileView(LoginRequiredMixin, DetailView):
"""View for profile."""

login_required = True
model = Profile
template_name = 'userprofile/profile.html'
slug_field = 'id'
Expand All @@ -18,9 +22,10 @@ def get_object(self):
return self.request.user


class EditProfile(UpdateView):
"""Add Album."""
class EditProfile(LoginRequiredMixin, UpdateView):
"""Edit users profile."""

login_required = True
template_name = 'userprofile/edit_profile.html'
model = Profile
form_class = ProfileForm
Expand Down