Commit 60619896 authored by jz143's avatar jz143

Merge branch 'master' into job_queue

parents b8291e60 ea753f78
......@@ -259,6 +259,3 @@ DEPENDENCIES
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
BUNDLED WITH
1.10.6
## Setup
* Install `iPhone Distribution: Duke University` certificate and private key to `System` keychain on signing server.
- Get Info > Access Control > Allow all applications to access this item
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
......@@ -35,8 +35,19 @@ body {
margin-bottom: 0;
line-height: 40px;
}
.brand{
img{
margin-left: -7px;
}
}
}
h1 {
color: $brand-primary;
}
.footer {
margin-top: 20px;
padding-top: 10px;
border-top: 1px solid #e5e5e5;
}
......@@ -61,7 +61,7 @@ class AppFilesController < ApplicationController
respond_to do |format|
if @app_file.save
format.html { redirect_to @app_file.app, notice: 'App version has been uploaded.' }
format.html { redirect_to @app_file.app, notice: 'App file has been uploaded.' }
format.json { render :show, status: :created, location: @app_file }
else
format.html { render :new }
......
......@@ -6,4 +6,14 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def user_not_authorized
flash[:alert] = "You are not authorized to perform this action."
redirect_to(request.referrer || root_path)
end
end
......@@ -10,6 +10,8 @@ class AppsController < ApplicationController
# GET /apps/1
# GET /apps/1.json
def show
authorize @app
# find latest versions for each platform
@latest_ios = @app.app_files.where(platform: 'iOS', code_signing_status: AppFile.code_signing_statuses[:signed]).order(created_at: :desc).first
@latest_android = @app.app_files.where(:platform => 'Android').order(created_at: :desc).first
......@@ -32,6 +34,8 @@ class AppsController < ApplicationController
@app = App.new(app_params)
@app.user = current_user
authorize @app
respond_to do |format|
if @app.save
format.html { redirect_to @app, notice: 'App was successfully created.' }
......@@ -46,6 +50,7 @@ class AppsController < ApplicationController
# PATCH/PUT /apps/1
# PATCH/PUT /apps/1.json
def update
authorize @app
respond_to do |format|
if @app.update(app_params)
format.html { redirect_to @app, notice: 'App was successfully updated.' }
......@@ -60,6 +65,7 @@ class AppsController < ApplicationController
# DELETE /apps/1
# DELETE /apps/1.json
def destroy
authorize @app
@app.destroy
respond_to do |format|
format.html { redirect_to apps_url, notice: 'App was successfully destroyed.' }
......
......@@ -66,7 +66,7 @@ class BuildIpaJob < ActiveJob::Base
'iPhone Distribution: Duke University', # cert name in Keychain
'-e', File.join(tmpdir, 'entitlements.plist'),
'-p', Rails.root.join('resources', 'ios_provisioning_profiles', 'CoLab_Member_Apps_20151.mobileprovision').to_s,
'-b', 'U6J58C8CJT.' + app_file.app.ios_application_identifier,
'-b', app_file.app.ios_application_identifier,
'-t', File.join(tmpdir, 'floatsign_tmp'),
File.join(tmpdir, 'Signed.ipa')
]
......
......@@ -14,4 +14,8 @@ class App < ActiveRecord::Base
'edu.duke.colab.' + self.id.to_s + '_' + self.bundle_identifier_suffix
end
def author_display_name
team_name || try(:user).try(:display_name)
end
end
......@@ -11,11 +11,11 @@ class AppFilePolicy < ApplicationPolicy
end
def show?
scope.where(:id => record.id).exists?
true
end
def create?
app_file.app.user == user
app_file.app.user == user || user.try(:admin?)
end
def new?
......@@ -23,7 +23,7 @@ class AppFilePolicy < ApplicationPolicy
end
def update?
app_file.app.user == user
app_file.app.user == user || user.try(:admin?)
end
def edit?
......@@ -31,7 +31,7 @@ class AppFilePolicy < ApplicationPolicy
end
def destroy?
app_file.app.user == user
app_file.app.user == user || user.try(:admin?)
end
end
......@@ -11,11 +11,11 @@ class AppPolicy < ApplicationPolicy
end
def show?
scope.where(:id => record.id).exists?
true
end
def create?
true
user
end
def new?
......@@ -23,15 +23,15 @@ class AppPolicy < ApplicationPolicy
end
def update?
app.user == user
app.user == user || user.try(:admin?)
end
def edit?
update?
update? || user.try(:admin?)
end
def destroy?
app.user == user
app.user == user || user.try(:admin?)
end
end
......@@ -11,7 +11,7 @@
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string><%= app_app_file_download_url(@app_file.app, @app_file, format: :ipa) %></string>
<string><%= app_app_file_download_url(@app_file.app, @app_file, protocol: 'https', format: :ipa) %></string>
</dict>
</array>
<key>metadata</key>
......
......@@ -2,7 +2,7 @@
<div class="row">
<div class="col-sm-12">
<p class="lead">Welcome to the Duke App Store. All apps below are free to download for use within the Duke community. Questions? Let us know at <%= link_to 'colab-ops@duke.edu', 'mailto:colab-ops@duke.edu' %></p>
<p class="lead">Welcome to the Duke App Store. &nbsp;All apps below are free to download for use within the Duke community. &nbsp;Questions? &nbsp;Let us know at <%= link_to 'colab-ops@duke.edu', 'mailto:colab-ops@duke.edu' %></p>
</div>
</div>
<div class="row app-list">
......@@ -14,7 +14,14 @@
</div>
<div class="col-xs-9">
<div class="caption">
<h4><%= app.name %></h4>
<h4>
<%= app.name %>
<small>
<% if app.author_display_name %>
by <%= app.author_display_name %>
<% end %>
</small>
</h4>
<p>
<%= link_to 'Details', app, class: 'btn btn-primary btn-sm' %>
</p>
......@@ -27,4 +34,8 @@
<br>
<%= link_to 'New App', new_app_path %>
<% if policy(App).create? %>
<%= link_to 'New App', new_app_path %>
<% else %>
<p>Developer? &nbsp;Sign in with your NetID to create new apps.</p>
<% end %>
<p id="notice"><%= notice %></p>
<div id="large_infobox" class="media">
<div class="media-left">
<%= image_tag 'appstore-icon.png', :size => "100x100", :alt => "default app logo" %>
</div>
<div class="media-body">
<h4 class="media-heading"><%= @app.name %></h4>
<p><%= @app.description %></p>
<%= button_tag(type: 'submit', class: "btn btn-primary btn-sm btn-download") do %>
<span class='download-icon'><%= image_tag 'download-icon.png', :size => '17x17' %></span>
<span>Download for iOS</span>
<% end %>
<h4 class="media-heading">
<%= @app.name %>
<small>
<% if @app.author_display_name %>
by <%= @app.author_display_name %>
<% end %>
</small>
</h4>
<p><%= simple_format @app.description %></p>
<% if @latest_ios %>
<p>
<a class="btn btn-primary btn-sm btn-download" href="itms-services://?action=download-manifest&url=<%= app_app_file_download_url(@app, @latest_ios, protocol: 'https', format: :plist) %>">
<span class='download-icon'><%= image_tag 'download-icon.png', :size => '17x17' %></span>
<span>Install on iPhone</span>
</a>
<p><strong>If this is your first download to iOS 9 or later:</strong> After you download one of our apps on iOS, go to Settings app, tap General > Profile. &nbsp;Under Enterprise App, tap Duke University, and then tap Trust Duke University.</p>
</p>
<% end %>
</div>
</div>
<% if @latest_android %>
......@@ -21,15 +30,6 @@
</p>
<% end %>
<% if @latest_ios %>
<p>
<%= link_to "View plist for iPhone", app_app_file_download_path(@app, @latest_ios, format: :plist) %>
</p>
<p>
<a href="itms-services://?action=download-manifest&url=<%= app_app_file_download_path(@app, @latest_ios, format: :plist) %>">Install on iPhone (must agree to prompt)</a>
</p>
<% end %>
<%#= debug @latest_ios %>
<%#= debug @latest_android %>
......@@ -39,5 +39,8 @@
<%= link_to 'View all versions of my app', app_app_files_path(@app) %> |
<% end %>
<%= link_to 'Edit', edit_app_path(@app) %> |
<% if policy(@app).update? %>
<%= link_to 'Edit', edit_app_path(@app) %> |
<% end %>
<%= link_to 'Back', apps_path %>
......@@ -27,7 +27,9 @@
</li>
</ul>
<div class="brand">
<%= image_tag 'appstore-logo.png', :size => "428x124" %>
<%= link_to root_path do %>
<%= image_tag 'appstore-logo.png', :size => "428x124", :class => 'img-responsive' %>
<% end %>
</div>
</div>
......@@ -35,9 +37,9 @@
<%= yield %>
<%= debug current_user %>
<%= debug DeployEnv.git_commit %>
<div class="footer">
<p>Innovation Co-Lab App Store version <%= DeployEnv.git_commit %>.</p>
</div>
</div>
</body>
......
......@@ -63,7 +63,7 @@ Rails.application.configure do
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: 'appstore.colab.duke.edu' }
config.action_mailer.default_url_options = { protocol: 'https', host: 'appstore.colab.duke.edu' }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
......
class AddAdminToUser < ActiveRecord::Migration
def change
add_column :users, :admin, :boolean
end
end
class ChangeDescriptionInApp < ActiveRecord::Migration
def change
change_column :apps, :description, :text
end
end
class AddTeamNameToApps < ActiveRecord::Migration
def change
add_column :apps, :team_name, :string
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151122224414) do
ActiveRecord::Schema.define(version: 20151124175550) do
create_table "app_files", force: :cascade do |t|
t.string "platform"
......@@ -33,7 +33,7 @@ ActiveRecord::Schema.define(version: 20151122224414) do
create_table "apps", force: :cascade do |t|
t.string "name"
t.string "description"
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
......@@ -42,6 +42,7 @@ ActiveRecord::Schema.define(version: 20151122224414) do
t.string "icon_content_type"
t.integer "icon_file_size"
t.datetime "icon_updated_at"
t.string "team_name"
end
create_table "reviews", force: :cascade do |t|
......@@ -71,6 +72,7 @@ ActiveRecord::Schema.define(version: 20151122224414) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "display_name"
t.boolean "admin"
end
end
Markdown is supported
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