Skip to content

Commit

Permalink
removing short name from review creating to keep things clear
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfs committed Feb 12, 2014
1 parent 93eb9e1 commit b42fe64
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
11 changes: 1 addition & 10 deletions reviews/templates/reviews/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
<h1>Create a New Review</h1>
<form action="." method="post" class="form-block">
{% csrf_token %}
<div class="form-row">
<div class="label-container">
<label for="name">Short Name</label>
</div>
<div class="input-container">
<input type="text" id="name" name="name" placeholder="Inform a name for your review" value="{{review.name}}">
<span class="help">The name will be used to create a unique url for your review. Make sure you choose something <strong>short</strong> and <strong>elegant</strong>.</span>
<span class="help">It will look like http://parsif.al/{{user.username}}/<strong>effort-estimation</strong>/</span>
</div>
</div>
<div class="form-row">
<div class="label-container">
<label for="title">Title</label>
Expand All @@ -28,6 +18,7 @@ <h1>Create a New Review</h1>
</div>
<div class="input-container">
<textarea rows="5" id="description" name="description" placeholder="Give a brief description of your systematic literature review" value="{{review.description}}"></textarea>
<span class="help">Try to keep it short, max 500 characters :)</span>
</div>
</div>
<div class="button-container">
Expand Down
2 changes: 2 additions & 0 deletions reviews/templates/reviews/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ <h2>Settings</h2>
</div>
<div class="input-container">
<input value="{{ review.name }}">
<span class="help">The name will be used to create a unique url for your review. Make sure you choose something <strong>short</strong> and <strong>elegant</strong>.</span>
<span class="help">It will look like http://parsif.al/{{user.username}}/<strong>example-review-name</strong>/</span>
</div>
</div>
<div class="form-row">
Expand Down
13 changes: 3 additions & 10 deletions reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,19 @@ def reviews(request, username):
def new(request):
review = Review()
if request.method == 'POST':
name = request.POST['name']
title = request.POST['title']
description = request.POST['description']
author = request.user

name = ' '.join(name.split()) # remove random spaces between words
name = ' '.join(title.split()) # remove random spaces between words
name = name.replace(' ', '-').lower()
review = Review(name = name, title = title, description = description, author=author)

if name and title:
if title:
review.save()
messages.add_message(request, messages.SUCCESS, 'Review created with success.')
return redirect('/' + review.author.username + '/' + review.name + '/')
else:
fields = []
if not name: fields.append('Short Name')
if not title: fields.append('Title')
message = 'The following fields are required: ' + ', '.join(fields) + '.'
message = 'Title is a required field.'
messages.add_message(request, messages.ERROR, message)

context = RequestContext(request, {'review': review})
return render_to_response('reviews/new.html', context)

Expand Down

0 comments on commit b42fe64

Please sign in to comment.