зеркало из https://github.com/mozilla/batucada.git
Reworking project edit / create forms
This commit is contained in:
Родитель
51f65ce7f9
Коммит
857b5bee57
|
@ -7,24 +7,18 @@ from messages.models import Message
|
|||
from projects.models import Project
|
||||
|
||||
|
||||
class ProtectedProjectForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ProtectedProjectForm, self).__init__(*args, **kwargs)
|
||||
protected = getattr(self.Meta, 'protected')
|
||||
project = kwargs.get('instance', None)
|
||||
|
||||
if not project or not project.featured:
|
||||
for field in protected:
|
||||
self.fields.pop(field)
|
||||
|
||||
|
||||
class ProjectForm(ProtectedProjectForm):
|
||||
class ProjectForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Project
|
||||
exclude = ('created_by', 'slug', 'featured')
|
||||
protected = ('template', 'css')
|
||||
fields = ('name', 'short_description', 'long_description')
|
||||
|
||||
|
||||
class ProjectDescriptionForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Project
|
||||
fields = ('detailed_description',)
|
||||
|
||||
|
||||
class ProjectContactUsersForm(forms.Form):
|
||||
|
|
|
@ -53,7 +53,7 @@ def edit(request, slug):
|
|||
else:
|
||||
form = project_forms.ProjectForm(instance=project)
|
||||
|
||||
return render_to_response('projects/edit.html', {
|
||||
return render_to_response('projects/project_edit_summary.html', {
|
||||
'form': form,
|
||||
'project': project,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
@ -82,9 +82,12 @@ def create(request):
|
|||
return http.HttpResponseRedirect(reverse('projects_show', kwargs={
|
||||
'slug': project.slug,
|
||||
}))
|
||||
else:
|
||||
messages.error(request,
|
||||
_("There was a problem creating your project."))
|
||||
else:
|
||||
form = project_forms.ProjectForm()
|
||||
return render_to_response('projects/create.html', {
|
||||
return render_to_response('projects/project_edit_summary.html', {
|
||||
'form': form,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
@ -99,8 +102,8 @@ def contact_followers(request, slug):
|
|||
form = project_forms.ProjectContactUsersForm(request.POST)
|
||||
if form.is_valid():
|
||||
form.save(sender=request.user)
|
||||
messages.add_message(request, messages.INFO,
|
||||
_("Message successfully sent."))
|
||||
messages.info(request,
|
||||
_("Message successfully sent."))
|
||||
return http.HttpResponseRedirect(reverse('projects_show', kwargs={
|
||||
'slug': project.slug,
|
||||
}))
|
||||
|
|
|
@ -1092,12 +1092,12 @@ header {}
|
|||
min-width: 68px;
|
||||
min-height: 24px;
|
||||
}
|
||||
.modal #profile-edit-nav {
|
||||
.modal #profile-edit-nav, .modal #project-edit-nav {
|
||||
float: left;
|
||||
width: 190px;
|
||||
height: 100%;
|
||||
}
|
||||
.modal #profile-edit-nav a {
|
||||
.modal #profile-edit-nav a, .modal #project-edit-nav a {
|
||||
display: block;
|
||||
padding-left: 18px;
|
||||
font-size: 12px;
|
||||
|
@ -1112,10 +1112,16 @@ header {}
|
|||
}
|
||||
.modal #profile-edit-nav .selected a,
|
||||
.modal #profile-edit-nav a:hover,
|
||||
.modal #project-edit-nav .selected a,
|
||||
.modal #project-edit-nav a:hover,
|
||||
#profile_edit.info #profile-edit-nav .info a,
|
||||
#profile_edit.image #profile-edit-nav .image a,
|
||||
#profile_edit.skills #profile-edit-nav .skills a,
|
||||
#profile_edit.interests #profile-edit-nav .interests a{
|
||||
#profile_edit.interests #profile-edit-nav .interests a,
|
||||
#project_edit.summary #project-edit-nav .summary a,
|
||||
#project_edit.description #project-edit-nav .description a,
|
||||
#project_edit.media #project-edit-nav .media a,
|
||||
#project_edit.links #project-edit-nav .links a {
|
||||
position: relative;
|
||||
color: #fff;
|
||||
text-shadow: -1px -1px 0 rgba(0,0,0,0.3);
|
||||
|
@ -1134,11 +1140,19 @@ header {}
|
|||
background: #2084CA;
|
||||
text-decoration: none;
|
||||
}
|
||||
.modal #project-edit-nav a:hover{
|
||||
background: #2084CA;
|
||||
text-decoration: none;
|
||||
}
|
||||
.modal #profile-edit-nav .selected a:after,
|
||||
#profile_edit.info #profile-edit-nav .info a:after,
|
||||
#profile_edit.image #profile-edit-nav .image a:after,
|
||||
#profile_edit.skills #profile-edit-nav .skills a:after,
|
||||
#profile_edit.interests #profile-edit-nav .interests a:after{
|
||||
#profile_edit.interests #profile-edit-nav .interests a:after,
|
||||
#project_edit.summary #project-edit-nav .summary a:after,
|
||||
#project_edit.description #project-edit-nav .description a:after,
|
||||
#project_edit.media #project-edit-nav .media a:after,
|
||||
#project_edit.links #project-edit-nav .links a:after {
|
||||
content: "\0020";
|
||||
display: block;
|
||||
width: 12px;
|
||||
|
@ -1346,4 +1360,19 @@ header {}
|
|||
}
|
||||
#splash #main asside #planet_drumbeat > h1 a:hover{
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: I wrote this, so we'll want to replace it :) (Paul) */
|
||||
span.help-text {
|
||||
font-size: 80%;
|
||||
color: #999;
|
||||
margin-bottom: 10px;
|
||||
display: block;
|
||||
}
|
||||
#project_edit input[type=text] {
|
||||
width: 300px;
|
||||
}
|
||||
#project_edit textarea {
|
||||
height: 90px;
|
||||
width: 400px;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load l10n_tags %}
|
||||
|
||||
{% block title %}{% if project %}{{ _('Edit Project') }}{% else %}{{ _('Create Project') }}{% endif %}{% endblock %}
|
||||
{% block bodyid %}project_edit{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="modal{% if project %} nav{% endif %}">
|
||||
<article>
|
||||
<h1>{% if project %}{{ _('Edit Project') }}{% else %}{{ _('Create Project') }}{% endif %}</h1>
|
||||
{% if project %}
|
||||
<nav id="project-edit-nav">
|
||||
<ul>
|
||||
<li class="summary"><a href="{% if project %}{% locale_url projects_edit slug=project.slug %}{% else %}{% locale_url projects_create %}{% endif %}">{{ _('Project Summary') }}</a></li>
|
||||
<li class="description"><a href="">{{ _('Detailed Description') }}</a></li>
|
||||
<li class="media"><a href="">{{ _('Images & Video') }}</a></li>
|
||||
<li class="links"><a href="">{{ _('Links & Content') }}</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
<fieldset>
|
||||
{% block form %}{% endblock %}
|
||||
</fieldset>
|
||||
</article>
|
||||
</section>
|
||||
{% endblock %}
|
|
@ -1,23 +1,31 @@
|
|||
{% extends "base.html" %}
|
||||
{% extends "projects/project_edit.html" %}
|
||||
{% load l10n_tags %}
|
||||
{% block title %}{{ _('Edit Project') }}{% endblock %}
|
||||
{% block bodyid %}project_edit{% endblock %}
|
||||
{% block bodyclasses %}project edit info{% endblock %}
|
||||
{% block bodyclasses %}project edit summary{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="modal">
|
||||
<article>
|
||||
<h1>{{ _('Edit Project') }}</h1>
|
||||
<fieldset>
|
||||
<form action="{% locale_url projects_edit slug=project.slug %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<p class="buttons">
|
||||
<a class="button" href="{%locale_url projects_show slug=project.slug %}">{{ _('Cancel') }}</a>
|
||||
<button type="submit" value="{{ _('Save') }}">{{ _('Save') }}</button>
|
||||
</p>
|
||||
</form>
|
||||
</fieldset>
|
||||
</article>
|
||||
</section>
|
||||
{% block form %}
|
||||
<form action="{% if project %}{% locale_url projects_edit slug=project.slug %}{% else %}{% locale_url projects_create %}{% endif %}" method="post">
|
||||
{% csrf_token %}
|
||||
<p>
|
||||
<label for="id_name">{{ _('Project name') }}</label>
|
||||
<span class="help-text">{{ _('A good project name is short and descriptive. People should know what your project is about without reading the description.') }}</span>
|
||||
{{ form.name }}
|
||||
{{ form.name.errors }}
|
||||
</p>
|
||||
<p>
|
||||
<label for="id_short_description">{{ _('One sentence description') }}</label>
|
||||
<span class="help-text">{{ _('This description will be used on the search results and project listing pages.') }}</span>
|
||||
{{ form.short_description }}
|
||||
{{ form.short_description.errors }}
|
||||
</p>
|
||||
<p>
|
||||
<label for="id_long_description">{{ _('Two paragraph description') }}</label>
|
||||
<span class="help-text">{{ _('This description is shown on the project page. It can go into a bit more detail about the project, but it should be brief and to the point.') }}</span>
|
||||
{{ form.long_description }}
|
||||
{{ form.long_description.errors }}
|
||||
</p>
|
||||
<p class="buttons">
|
||||
<a class="button" href="{% locale_url projects_gallery %}">{{ _('Cancel') }}</a>
|
||||
<button type="submit" value="{{ _('Create') }}">{{ _('Create') }}</button>
|
||||
</p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
Загрузка…
Ссылка в новой задаче