Commit 904b5418 authored by Sara Kuqi's avatar Sara Kuqi
Browse files

edit button in preparation-table with div. After update rendering. Password reset with mailgun

parent f0ca3a25
......@@ -217,13 +217,14 @@ input.transparent-input{
background-color: transparent;
border: none;
color:#008fb3;
margin-left: 0;
}
.button-link:hover {
color: #006680;
text-decoration: underline;
}
.panel-default{
height:400px;
max-height:400px;
width: 145%;
border: 0;
overflow-y: auto;
......@@ -239,9 +240,28 @@ text-decoration: underline;
div.absolute {
margin-top:10px;
margin-left: 570px;
}
div.absolutem {
margin-top:10px;
margin-left: 590px;
}
.div-table{
display:table;
width: auto !important;
// background-color:#eee;
border-spacing:5px;/*cellspacing:poor IE support for this*/
}
.div-table-row{
display:table-row;
width:auto;
clear:both;
}
.div-table-col{
float:left;/*fix for buggy browsers*/
display:table-column;
width:200px;
border:1px solid #d0d0d0;
text-align:center;
// background-color: gray;
padding: 12px;
}
class PasswordResetsController < ApplicationController
before_action :get_user, only: [:edit, :update]
before_action :valid_user, only: [:edit, :update]
before_action :check_expiration, only: [:edit, :update]
before_action :check_expiration, only: [:edit, :update]
def new
end
......@@ -51,10 +51,9 @@ class PasswordResetsController < ApplicationController
def valid_user
unless (@user && @user.activated? &&
@user.authenticated?(:reset, params[:id]))
#redirect_to root_url
render 'password_resets/edit'
redirect_to root_url
end
end
end
# Checks expiration of reset token
......
......@@ -21,10 +21,10 @@ class SamplesController < ApplicationController
def index
@sample = if params[:display_sample].present?
Sample.find(params[:display_sample].to_i)
Sample.find(params[:id].to_i)
else
current_user.samples.build
end
end
@title = "Listing Samples"
status = params.delete :status
case status
......@@ -36,12 +36,12 @@ class SamplesController < ApplicationController
if operator?
@samples = Sample.where('status IN (?)', ["measured"])
end
else
else
if operator?
@samples = current_user.samples.where('status IN (?)' , ["in preparation"])
end
end
end
end
def edit
@sample = Sample.find(params[:id])
......@@ -55,11 +55,12 @@ class SamplesController < ApplicationController
def update
sample = Sample.find(params[:id])
if sample.update_attributes(sample_params)
flash[:success] = "Sample updated"
redirect_to request.referrer && "?display_sample=#{sample.id}"
sample.touch
flash[:success] = "Sample updated"
else
#render 'root_path'
flash[:danger] = sample.errors.full_messages.to_sentence
end
redirect_to (request.referer).pathmap + "?display_sample=#{sample.id}"
end
def show
......@@ -92,7 +93,7 @@ class SamplesController < ApplicationController
sample.status = "submitted"
sample.save
end
redirect_to :back && "?display_sample=#{sample.id}"
redirect_to (request.referer).pathmap + "?display_sample=#{sample.id}"
end
def ReleaseMeasurment
......@@ -101,7 +102,7 @@ class SamplesController < ApplicationController
sample.status = "measured"
sample.save
end
redirect_to :back && "?display_sample=#{sample.id}"
redirect_to (request.referer).pathmap + "?display_sample=#{sample.id}"
end
private
......
......@@ -13,6 +13,11 @@ class UsersController < ApplicationController
def show
@sample=Sample.new
@sample = if params[:display_sample].present?
Sample.find(params[:display_sample].to_i)
else
current_user.samples.build
end
@user = User.find(params[:id])
if operator?
@samples = @user.samples.where('status <> ? OR user_id = ?','in preparation',current_user.id).paginate(page: params[:page])
......
class UserMailer < ApplicationMailer
default from: 'notifications@example.com'
def welcome_email(user)
def measured_email(user)
@user = user
@url = 'http://example.com/login'
mail(to: @user.email, subject: 'Welcome to Mol_app')
#@url = 'http://example.com/login'
mail(to: @user.email, subject: 'Your sample has been measured')
end
def password_reset(user)
@user = user
mail to: user.email, subject: "Password reset"
......
class User < ApplicationRecord
has_many :samples, dependent: :destroy
has_many :microposts, dependent: :destroy
self.inheritance_column = :type
attr_accessor :remember_token, :activation_token, :reset_token
before_save { self.email = email.downcase }
validates :name, presence: true, length: { maximum: 50 }
......@@ -31,8 +27,7 @@ class User < ApplicationRecord
def feed
Sample.where("user_id = ?", id)
end
end
# Returns the hash digest of the given string.
def self.digest(string)
......
<% provide(:title, "Edit sample") %>
<%if @sample.status=="in preparation"%>
<table class="table table-bordered table-nonfluid" id="tab_logic" style="margin: 70px 0px 20px 15px">
<thead>
<tr>
<th class="text-center">
ID
</th>
<th class="text-center">
Name
</th>
<th class="text-center">
Formula
</th>
<th class="text-center">
Action
</th>
</tr>
</thead>
<tbody>
<tr>
<%= form_for(@sample) do |f| %>
<td>
<%= @sample.id%>
</td>
<td>
<%= f.text_field :name, class: 'form-control transparent-input' %>
</td>
<td>
<%= f.text_field :formula, class: 'form-control transparent-input' %>
</td>
<td>
<%= f.submit "save", class: 'button-link' %>
</td>
<%end%>
</tr>
</tbody>
</table>
<%end%>
<!-- <%= form_for(@sample) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<fieldset class="form-group">
<%= f.label :Name %>
<%= f.text_field :name, class: 'form-control' %>
<%= f.label :Formula %>
<%= f.text_field :formula, class: 'form-control' %>
</fieldset>
<%= f.submit "update", class: "btn btn-success" %>
<% end %> -->
<div class="div-table">
<div class="div-table-row">
<div class="div-table-col" style="font-weight:bold">ID</div>
<div class="div-table-col" style="font-weight:bold"> Name</div>
<div class="div-table-col" style="font-weight:bold">Formula</div>
<div class="div-table-col" style="font-weight:bold">Status</div>
<div class="div-table-col" style="font-weight:bold">Action</div>
</div>
<div class="div-table-row">
<%= form_for(@sample) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<div class="div-table-col" style="text-align:left"><%= @sample.id%></div>
<div class="div-table-col" style="padding:0px"> <%= f.text_field :name, class: 'form-control' %></div>
<div class="div-table-col" style="padding:0px"><%= f.text_field :formula, class: 'form-control' %></div>
<div class="div-table-col" style="text-align:left"><%= @sample.status%></div>
<div class="div-table-col" style="padding:7px"> <%= f.submit "save", class: "button-link"%></div>
<%end%>
</div>
</div>
<% end %>
<div style='margin-top:50px'>
<% if operator? && @sample.status=="submitted"%>
......
......@@ -86,11 +86,11 @@ $(document).ready(function(){
<%end%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<%if @sample.persisted?%>
<%if @sample.persisted? %>
<div class="panel panel-default" id="show">
<%= render 'samples/show'%>
</div>
......
......@@ -4,14 +4,13 @@
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Welcome to example.com, <%= @user.name %></h1>
<h1>Hello, <%= @user.name %></h1>
<p>
You have successfully signed up to Mol_app.com,
your username is: <%= @user.login %>.<br>
Your sample has been successfully measured.<br>
</p>
<p>
To login to the site, just follow this link: <%= @url %>.
To see the report, just follow this link: <%=#%>.
</p>
<p>Thanks for joining and have a great day!</p>
<p>Have a great day!</p>
</body>
</html>
Hello, <%= @user.name %>
===============================================
Your sample has been successfully measured.
To see the report, just follow this link: <%= @url %>.
Have a great day!
Welcome to example.com, <%= @user.name %>
===============================================
You have successfully signed up to example.com,
your username is: <%= @user.login %>.
To login to the site, just follow this link: <%= @url %>.
Thanks for joining and have a great day!
api_key: 'key-d977f6da2e29f864240f769958f16017'
domain: 'sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org'
username: 'postmaster@sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org'
password: '7a7d729689e994c6f24cb8744f0e11fa'
# gmail_username: 'username@gmail.com'
# gmail_password: 'gmail password'
......@@ -24,7 +24,19 @@ Rails.application.configure do
config.cache_store = :null_store
end
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'localhost:3000'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.mailgun.org',
:port => '587',
:authentication => :plain,
:user_name => 'postmaster@sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org',
:password => '7a7d729689e994c6f24cb8744f0e11fa',
:domain => 'sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org',
:enable_starttls_auto => true
}
# Don't care if the mailer can't send.
#3config.action_mailer.raise_delivery_errors = false
......@@ -46,7 +58,7 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.action_mailer.default_url_options = {:host => "dev.localhost:3000"}
#1111config.action_mailer.default_url_options = {:host => "dev.localhost:3000.com"}
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
......
......@@ -16,15 +16,15 @@ Rails.application.configure do
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'www.localhost:3000.com'
host = 'localhost:3000'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:address => 'smtp.mailgun.org',
:port => '587',
:authentication => :plain,
:user_name => 'myname@gmail.com',
:password => 'mypassword'
:domain => 'gmail.com',
:user_name => 'postmaster@sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org',
:password => '7a7d729689e994c6f24cb8744f0e11fa',
:domain => 'sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org',
:enable_starttls_auto => true
}
......@@ -99,5 +99,5 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.action_mailer.default_url_options = { :host => "www.localhost:3000.com" }
#222config.action_mailer.default_url_options = { :host => "www.localhost:3000.com" }
end
......@@ -25,7 +25,7 @@ Rails.application.routes.draw do
resources :users
resources :operators, controller: 'users', type: 'Operator'
resources :chemists, controller: 'users', type: 'Chemist'
resources :samples, only: [:create, :destroy, :show, :edit]
resources :samples, only: [:create, :destroy, :show, :edit, :update]
resources :password_resets, only: [:new, :create, :edit, :update]
resources :microposts, only: [:create, :destroy]
......@@ -36,7 +36,7 @@ Rails.application.routes.draw do
get :ReleaseMeasurment
end
end
resources :results do
post :sort
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment