Skip to content

Commit

Permalink
Display a alert about user credentials along with download urls of a …
Browse files Browse the repository at this point in the history
…dataset. Other tweaks too.
  • Loading branch information
manxingxing committed Aug 14, 2013
1 parent b20fdc2 commit 2b2d515
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/datasets.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,4 @@ ul#downloaders {
.help-text {display: block; color: #737373; }
&:after {content: ''; clear: both; display: block; }
ul>li {list-style-type: disc; list-style-position: inside; line-height: 0.7em;}
}
}
10 changes: 8 additions & 2 deletions app/assets/stylesheets/style.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,15 @@ div#actions + div#info {
margin-bottom: 7px;
}

.show_download_link_modal .close_hint {
.show_download_link_modal {
.security-alert {
color: red;
margin: 0px;
}
.close_hint {
color: #8A8A8A;
margin: 5px 0 0 0;
}
}

#modal { top: 20px; }
Expand Down Expand Up @@ -996,4 +1002,4 @@ noscript {
}
}
.right { float: right !important;}
.left { float: left !important;}
.left { float: left !important;}
2 changes: 1 addition & 1 deletion app/controllers/datasets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def show
end

def index
datasets = Dataset.select("id, title")
datasets = Dataset.select("id, title").order(:id)

respond_to do |format|
format.json { render :json => datasets }
Expand Down
8 changes: 3 additions & 5 deletions app/models/datacolumn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ def predefined?

# override the datagroup method.
# when datagroup is not assigned, used NullDatagroup instead.
alias fetch_datagroup_via_datagroup_id datagroup
private :fetch_datagroup_via_datagroup_id
def datagroup
if self.datagroup_id
Datagroup.where(id: datagroup_id).first
else
NullDatagroup.new
end
fetch_datagroup_via_datagroup_id || NullDatagroup.new
end

# returns the first 'count' number unique imported values
Expand Down
6 changes: 0 additions & 6 deletions app/models/paperproposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class Paperproposal < ActiveRecord::Base
:source => :paperproposal_votes, :conditions => {:project_board_vote => true }
has_many :for_data_request_votes, :class_name => "PaperproposalVote",
:source => :paperproposal_votes, :conditions => {:project_board_vote => false }
# has_many through association with User model via paperproposal_votes joint table.
has_many :coordinators, :class_name => "User", :source => :user, :through => :paperproposal_votes,
:conditions => ['project_board_vote = ?',true]

# habtm association with Dataset model.
before_destroy :reset_download_rights # needs to be before association definition,see https://rails.lighthouseapp.com/projects/8994/tickets/4386
Expand All @@ -45,9 +42,6 @@ class Paperproposal < ActiveRecord::Base
# one-to-many association with Freeformat model.
has_many :freeformats, :as => :freeformattable, :dependent => :destroy

scope :has_state, lambda{|s| where(:state=>s)}
accepts_nested_attributes_for :authors

validates_presence_of :title, :rationale, :author_id

STATES = {
Expand Down
13 changes: 13 additions & 0 deletions app/views/datasets/_popup_display_download_url.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@
\|
%a{:href => '#', :class => 'show_eml_url'}
EML
- if current_user
%p.security-alert The link contains your user credentials, Please DO NOT share with others.
%textarea.download_urls{:readonly => 'readonly', :onclick => 'this.focus();this.select()'}
= url_csv_categories
%p.close_hint
Click somewhere outside or press ESC to close

:javascript
function alert_if_with_user_credential() {
if($("##{modal_id} .download_urls").val().indexOf("user_credential") != -1 ) {
$(".security-alert").fadeIn('fast');
}
else {
$(".security-alert").fadeOut('fast');
}
}
$("##{link_id}").click(function(e) {
$("##{modal_id}").modal(
{
Expand All @@ -40,14 +50,17 @@
);
$("##{modal_id} .show_csv_url_with_categories").click(function(e) {
$("##{modal_id} .download_urls").val("#{url_csv_categories}");
alert_if_with_user_credential()
e.preventDefault();
});
$("##{modal_id} .show_csv_url_without_categories").click(function(e) {
$("##{modal_id} .download_urls").val("#{url_csv_plain}");
alert_if_with_user_credential()
e.preventDefault();
});
$("##{modal_id} .show_eml_url").click(function(e) {
$("##{modal_id} .download_urls").val("#{url_eml}");
alert_if_with_user_credential()
e.preventDefault();
});
e.preventDefault();
Expand Down

0 comments on commit 2b2d515

Please sign in to comment.