Skip to content

Commit

Permalink
author - #60
Browse files Browse the repository at this point in the history
  • Loading branch information
andreslucena committed Mar 28, 2012
1 parent 24b9a61 commit 92c2018
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
22 changes: 22 additions & 0 deletions webapp/app/assets/javascripts/forms.js
@@ -1,3 +1,18 @@


function check_author_checker(){
// para el checkbox de "Soy el autor"
if ( $('.author_myself').is(':checked') ) {
$('.author-field').slideUp('slow');
$('.author-field input').removeAttr('required');
} else {
$('.author-field').slideDown('slow');
$('.author-field input').attr('required', 'required');
}
}



$(function(){

// date and time picker for Fecha
Expand Down Expand Up @@ -348,4 +363,11 @@ $(function(){
source: country_list
});

// para el checkbox de "Soy el autor"
check_author_checker();

$('.author_myself').on('change', function(){
check_author_checker();
})

});
7 changes: 5 additions & 2 deletions webapp/app/models/content.rb
Expand Up @@ -23,8 +23,11 @@ class Content
belongs_to :user
field :user_id, type: String

field :author_id, type: String
field :author, type: String
# Puede ser que el mismo usuario creador de la ficha
# sea el autor de la obra
field :author_myself, type: String
# o sino puede ser un nombre/link
field :author_name, type: String
field :author_link, type: String

#address
Expand Down
11 changes: 6 additions & 5 deletions webapp/app/views/partials/_form_for_content.html.erb
@@ -1,10 +1,11 @@
<div class="form-field">
<%= check_box_tag "author_myself" %>
<label for="author_myself" id="author_myself_label">Soy el autor</label>
</div>
<% if user_signed_in? %>
<%= f.check_box :author_myself, :class => "author_myself" do %>
Soy el autor
<% end %>
<% end %>

<div class="form-field author-field">
<%= f.text_field :author, class: 'span8' %>
<%= f.text_field :author_name, class: 'span8', :required => "true" %>
</div>

<div class="form-field author-field">
Expand Down
13 changes: 11 additions & 2 deletions webapp/app/views/partials/_metadata.html.erb
Expand Up @@ -17,8 +17,17 @@
<p><strong>Latitud:</strong> <%= content.latitude %></p>
<p><strong>Longitud:</strong> <%= content.longitude %></p>
<p><strong>Tags:</strong> <%= content.tag_list %></p>
<p><strong>Autor:</strong> <%= content.author %></p>
<p><strong>Autor (link):</strong> <%= content.author_link %></p>

<% if content.author_myself == "1" %>
<p><strong>Autor:</strong><%= link_to content.user.username, profile_path(content.user) %></p>
<% else %>
<% if content.author_link %>
<p><strong>Autor:</strong> <%= link_to content.author_name, content.author_link %></p>
<% else %>
<p><strong>Autor:</strong> <%= content.author_name %></p>
<% end %>
<% end %>

</div>
<div class="well">
<% if content.user %>
Expand Down
3 changes: 3 additions & 0 deletions webapp/config/locales/es.yml
Expand Up @@ -201,6 +201,9 @@ es:
mongoid:
attributes:
content:
author_myself: ""
author_name: "Autor (nombre)"
author_link: "Autor (URL)"
title: "Título"
tag_list: "Etiquetas"
happened_at: "¿Cuándo ha ocurrido?"
Expand Down

0 comments on commit 92c2018

Please sign in to comment.