add volunteer profile, fixes #116
This commit is contained in:
parent
463a57172e
commit
1b6d965a75
|
@ -1,11 +0,0 @@
|
|||
from django import forms
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
class ProfileForm(forms.ModelForm):
|
||||
email = forms.EmailField()
|
||||
|
||||
class Meta:
|
||||
model = models.Profile
|
||||
fields = []
|
20
src/profiles/migrations/0002_profile_description.py
Normal file
20
src/profiles/migrations/0002_profile_description.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-04-13 12:42
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('profiles', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='description',
|
||||
field=models.TextField(default='', help_text='Please include any info you think could be relevant, like drivers license, first aid certificates, crafts, skills and previous experience.'),
|
||||
),
|
||||
]
|
25
src/profiles/migrations/0003_auto_20170413_1703.py
Normal file
25
src/profiles/migrations/0003_auto_20170413_1703.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-04-13 15:03
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('profiles', '0002_profile_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, default='', help_text='Your name or handle', max_length=200),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, default='', help_text='Please include any info you think could be relevant, like drivers license, first aid certificates, crafts, skills and previous experience.'),
|
||||
),
|
||||
]
|
|
@ -18,6 +18,19 @@ class Profile(CreatedUpdatedModel, UUIDModel):
|
|||
help_text=_('The django user this profile belongs to.'),
|
||||
)
|
||||
|
||||
name = models.CharField(
|
||||
max_length=200,
|
||||
default='',
|
||||
blank=True,
|
||||
help_text='Your name or handle'
|
||||
)
|
||||
|
||||
description = models.TextField(
|
||||
default='',
|
||||
blank=True,
|
||||
help_text='Please include any info you think could be relevant, like drivers license, first aid certificates, crafts, skills and previous experience. Please also include availability if you are not there for the full week.',
|
||||
)
|
||||
|
||||
@property
|
||||
def email(self):
|
||||
return self.user.email
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends 'profiles/profile_base.html' %}
|
||||
{% extends 'profile_base.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends 'profiles/profile_base.html' %}
|
||||
{% extends 'profile_base.html' %}
|
||||
{% load i18n %}
|
||||
{% load account %}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends 'profiles/profile_base.html' %}
|
||||
{% extends 'profile_base.html' %}
|
||||
|
||||
{% load account %}
|
||||
{% load bootstrap3 %}
|
||||
|
|
23
src/profiles/templates/profile_base.html
Normal file
23
src/profiles/templates/profile_base.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load account %}
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="btn-group btn-group-justified hidden-xs">
|
||||
{% include 'profile_base_buttons.html' %}
|
||||
</div>
|
||||
<div class="btn-group-vertical visible-xs">
|
||||
{% include 'profile_base_buttons.html' %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<p><i><b>You are logged in as {{ request.user.email }}</b></i></p>
|
||||
|
||||
<hr />
|
||||
{% block profile_content %}{% endblock %}
|
||||
|
||||
{% endblock %}
|
28
src/profiles/templates/profile_base_buttons.html
Normal file
28
src/profiles/templates/profile_base_buttons.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<a href="{% url 'profiles:detail' %}" class="btn btn-black">
|
||||
Profile
|
||||
</a>
|
||||
<a href="{% url 'account_change_password' %}" class="btn btn-black">
|
||||
Change password
|
||||
</a>
|
||||
<a href="{% url 'account_email' %}" class="btn btn-black">
|
||||
Manage emails
|
||||
</a>
|
||||
{% if user.is_authenticated and user.orders.exists %}
|
||||
<a href="{% url 'shop:order_list' %}" class="btn btn-black">
|
||||
Orders
|
||||
</a>
|
||||
{% if has_tickets %}
|
||||
<a href="{% url 'shop:ticket_list' %}" class="btn btn-black">
|
||||
Tickets
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if user.creditnotes.exists %}
|
||||
<a href="{% url 'shop:creditnote_list' %}" class="btn btn-black">
|
||||
Credit Notes
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a href="{% url 'account_logout' %}" class="btn btn-black">
|
||||
Logout
|
||||
</a>
|
||||
|
15
src/profiles/templates/profile_detail.html
Normal file
15
src/profiles/templates/profile_detail.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% extends 'profile_base.html' %}
|
||||
|
||||
{% block profile_content %}
|
||||
<p class="lead">The information in your profile is only visible to team responsible and organisers.</p>
|
||||
<p class="lead">If you intend to join one or more teams you can use the profile to help the team responsible understand who you are and what you have to offer.</p>
|
||||
<hr>
|
||||
<h3>Your Profile</h3>
|
||||
<dl>
|
||||
<dt>Name</dt>
|
||||
<dd>{{ profile.name|default:"N/A" }}</dd>
|
||||
<dt>Description</dt>
|
||||
<dd>{{ profile.description|default:"N/A" }}</dd>
|
||||
</dl>
|
||||
<a href="{% url 'profiles:update' %}" class="btn btn-black"><i class="fa fa-edit"></i> Edit Profile</a>
|
||||
{% endblock profile_content %}
|
12
src/profiles/templates/profile_form.html
Normal file
12
src/profiles/templates/profile_form.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
{% extends 'profile_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% block profile_content %}
|
||||
<h4>Update Profile</h4>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
<button type="submit" class="btn btn-black"><i class="fa fa-save"></i> Submit</button>
|
||||
<a href="{% url 'profiles:detail' %}" class="btn btn-black"><i class="fa fa-remove"></i> Cancel</a>
|
||||
</form>
|
||||
{% endblock profile_content %}
|
|
@ -1,45 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load account %}
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3>Logged in as {{ request.user.email }}</h3>
|
||||
<p>
|
||||
<a href="{% url 'account_change_password' %}" class="btn btn-black">
|
||||
Change password
|
||||
</a>
|
||||
<a href="{% url 'account_email' %}" class="btn btn-black">
|
||||
Manage emails
|
||||
</a>
|
||||
<a href="{% url 'account_logout' %}" class="btn btn-black">
|
||||
Logout
|
||||
</a>
|
||||
|
||||
{% if user.is_authenticated and user.orders.exists %}
|
||||
<a href="{% url 'shop:order_list' %}" class="btn btn-black">
|
||||
Orders
|
||||
</a>
|
||||
|
||||
{% if has_tickets %}
|
||||
<a href="{% url 'shop:ticket_list' %}" class="btn btn-black">
|
||||
Tickets
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if user.creditnotes.exists %}
|
||||
<a href="{% url 'shop:creditnote_list' %}" class="btn btn-black">
|
||||
Credit Notes
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</p>
|
||||
<hr />
|
||||
</div>
|
||||
</div>
|
||||
{% block profile_content %}{% endblock %}
|
||||
|
||||
{% endblock %}
|
|
@ -1,4 +0,0 @@
|
|||
{% extends 'profiles/profile_base.html' %}
|
||||
|
||||
{% block profile_content %}
|
||||
{% endblock %}
|
|
@ -3,12 +3,12 @@ from django.views.generic import DetailView, UpdateView
|
|||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.contrib import messages
|
||||
|
||||
|
||||
from . import models, forms
|
||||
from . import models
|
||||
|
||||
|
||||
class ProfileDetail(LoginRequiredMixin, DetailView):
|
||||
model = models.Profile
|
||||
template_name = 'profile_detail.html'
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
return models.Profile.objects.get(user=self.request.user)
|
||||
|
@ -16,19 +16,14 @@ class ProfileDetail(LoginRequiredMixin, DetailView):
|
|||
|
||||
class ProfileUpdate(LoginRequiredMixin, UpdateView):
|
||||
model = models.Profile
|
||||
form_class = forms.ProfileForm
|
||||
fields = ['name', 'description']
|
||||
success_url = reverse_lazy('profiles:detail')
|
||||
template_name = 'profile_form.html'
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
return models.Profile.objects.get(user=self.request.user)
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(ProfileUpdate, self).get_form_kwargs()
|
||||
kwargs['initial'] = {'email': self.object.user.email}
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form, **kwargs):
|
||||
self.object.user.email = form.cleaned_data['email']
|
||||
self.object.user.save()
|
||||
messages.info(self.request, 'Your profile has been updated.')
|
||||
return super(ProfileUpdate, self).form_valid(form, **kwargs)
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ Teams | {{ block.super }}
|
|||
{% block content %}
|
||||
|
||||
<h3>{{ camp.title }} Teams</h3>
|
||||
<p>This is a list of the teams for {{ camp.title }}. To join a team just press the Join button. You can also leave a team if you are already a member (please let the team responsible know why!).</p>
|
||||
<p>This is a list of the teams for {{ camp.title }}. To join a team just press the Join button, but please put some info in your <a href="{% url 'profiles:detail' %}">profile</a> first, so the team responsible has some idea who you are.</p>
|
||||
<p>You can also leave a team of course, but please let the team responsible know why :)</p>
|
||||
<p>Team memberships need to be approved by a team responsible. You will receive a message when your membership has been approved.</p>
|
||||
<p>At {{ camp.title }} all organisers and volunteers buy full tickets like everyone else. In the future our budget may allow for discounts or free tickets for volunteers, but not this year. However: Please let us know if you can't afford a ticket - we will figure something out!</p>
|
||||
<p>We currently have {{ teams.count }} teams for {{ camp.title }}:</p>
|
||||
|
|
Loading…
Reference in a new issue