Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ gem 'redactor-rails'
gem 'carrierwave'
gem 'mini_magick'
gem 'cancan'
gem 'tzinfo-data'
gem 'coffee-script-source', '1.8.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand All @@ -39,7 +41,6 @@ gem 'twitter-bootstrap-rails'

# To include font-awesome icons
gem 'font-awesome-rails'

# Author: Mohammed El-Ansary
# 7.4.2015
# Simplecov to evaluate tests
Expand Down
50 changes: 26 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ GEM
tzinfo (~> 1.1)
arel (6.0.0)
bcrypt (3.1.10)
bcrypt (3.1.10-x86-mingw32)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
byebug (4.0.5)
columnize (= 0.9.0)
cancan (1.6.10)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
Expand All @@ -54,13 +53,12 @@ GEM
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1)
coffee-script-source (1.8.0)
columnize (0.9.0)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
devise (3.4.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -71,19 +69,18 @@ GEM
diff-lcs (1.2.5)
docile (1.1.5)
erubis (2.7.0)
execjs (2.4.0)
execjs (2.5.2)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
font-awesome-rails (4.3.0.0)
railties (>= 3.2, < 5.0)
globalid (0.3.3)
globalid (0.3.5)
activesupport (>= 4.1.0)
hike (1.2.3)
i18n (0.7.0)
jbuilder (2.2.11)
jbuilder (2.2.13)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
Expand All @@ -96,12 +93,14 @@ GEM
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.4.3)
mini_magick (4.1.0)
mini_magick (4.2.3)
mini_portile (0.6.2)
minitest (5.5.1)
minitest (5.6.0)
multi_json (1.11.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
rack (1.6.0)
rack-test (0.6.3)
Expand All @@ -119,11 +118,11 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.5)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.0)
actionpack (= 4.2.0)
Expand All @@ -132,6 +131,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
redactor-rails (0.5.0)
devise
mime-types
Expand All @@ -156,7 +156,7 @@ GEM
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
sass (3.4.13)
sass-rails (5.0.1)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
Expand All @@ -170,20 +170,17 @@ GEM
multi_json (~> 1.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
slop (3.6.0)
spring (1.3.3)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
spring (1.3.4)
sprockets (3.0.1)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sqlite3 (1.3.10-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
tilt (1.4.1)
turbolinks (2.5.3)
coffee-rails
Expand All @@ -194,25 +191,29 @@ GEM
railties (~> 4.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
tzinfo-data (1.2015.3)
tzinfo (>= 1.0.0)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
rack (>= 1.0)
web-console (2.1.1)
web-console (2.1.2)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
byebug
cancan
carrierwave
coffee-rails (~> 4.1.0)
coffee-script-source (= 1.8.0)
devise
factory_girl_rails
font-awesome-rails
Expand All @@ -229,5 +230,6 @@ DEPENDENCIES
sqlite3
turbolinks
twitter-bootstrap-rails
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)
Binary file added UML Wordspace/sequence_diagram_s27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions app/controllers/magazines_controller.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def index
# GET /magazines/1
# GET /magazines/1.json
def show
@join = Requestjoiningmagazine.where(
'user_id = ? AND magazine_id = ?',
current_user.id,
params[:id])
@users = @magazine.users
@articles = Article.where(magazine_id: params[:id])
end
Expand Down Expand Up @@ -92,6 +96,54 @@ def check_for_cancel
redirect_to @magazine
end

# Request joining a magazine
def join
joinh = { 'user_id' => current_user.id, 'magazine_id' => params[:id] }
Requestjoiningmagazine.create(joinh)
@magazine = Magazine.find(params[:id])
redirect_to @magazine
end

def showrequests
#Author:Mina Hany
#5.4.2015
#Obtain all requests having the magaine id and get the
#corresponding users and put them in array to view them
@request = Requestjoiningmagazine.where('magazine_id = ?', params[:id])
@users = []
@request.each do |r|
@users.push(User.find(r.user_id))
end
end

def approverequest
#Author:Mina Hany
#5.4.2015
#Remove the specified request from the joining requests and
#add the specified user to magaine's collaborators
@req = Requestjoiningmagazine.where(
"user_id = ? AND magazine_id = ?",
params[:user],
params[:id])
@req.destroy_all
@magazine = Magazine.find(params[:id])
@user = User.find(params[:user])
@magazine.users << @user
redirect_to action: :showrequests
end

def rejectrequest
#Author:Mina Hany
#5.4.2015
#Remove the specified request from the joining requests
@req = Requestjoiningmagazine.where(
"user_id = ? AND magazine_id = ?",
params[:user],
params[:id])
@req.destroy_all
redirect_to action: :showrequests
end

private

# Use callbacks to share common setup or constraints between actions.
Expand Down
5 changes: 5 additions & 0 deletions app/models/ability.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def initialize(user)
can :show, Comment
can :show, Reply
can :show, Magazine
can :join, Magazine

unless user.nil?
can :update, Article do |article|
article.user_id == user.id
Expand All @@ -33,6 +35,9 @@ def initialize(user)
# Author: Mayar
# Date: 5.4.2015
# Only managize managers can update magazines
can :showrequests, Magazine
can :approverequest, Magazine
can :rejectrequest, Magazine
can :update, Magazine do |m|
(m.users.include? user)
end
Expand Down
5 changes: 5 additions & 0 deletions app/models/magazine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# 5.4.2015
# Magazines model
class Magazine < ActiveRecord::Base
# many-to-many relationship between magazine
# requested to join to by many users
has_many :requestjoiningmagazines
has_many :users, through: :requestjoiningmagazines

# Author: Mohammed El-Ansary
# 5.4.2015

Expand Down
4 changes: 4 additions & 0 deletions app/models/requestjoiningmagazine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Requestjoiningmagazine < ActiveRecord::Base
belongs_to :user
belongs_to :magazine
end
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# User Model
class User < ActiveRecord::Base
# many-to-many relationship between user requests joining magazine
has_many :requestjoiningmagazines
has_many :magazines, through: :requestjoiningmagazines

# to upload avatar for user
mount_uploader :avatar, AvatarUploader
has_many :magazines
Expand Down
7 changes: 7 additions & 0 deletions app/views/magazines/show.html.erb
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<% if @join.present? %>
<%= flash[:notice] = "You have requested joining this magazine." %>
<% end %>
<div class="view-wrapper">
<div class="row">
<div class="col-sm-3">
Expand All @@ -21,6 +24,10 @@
<%= link_to "New Article", new_article_path(magazine_id: @magazine.id) %>

<%end%>
<%= link_to 'Join this magazine', action: "join" %>
<% if @magazine.users.exists?(current_user) %>
<%= link_to 'View joining requests', action: 'showrequests'%>
<% end %>
</div>
</div>
<div class="row">
Expand Down
40 changes: 40 additions & 0 deletions app/views/magazines/showrequests.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div class="editor" >
<h1>Joining requests</h1>

<div class="row">
<div class="col-sm-3 ">
Name
</div>
<div class="col-sm-3 ">
email
</div>
</div>

<! display list of user requested joining the magazine >
<% @users.each do |user| %>

<div class="row">
<div class="col-sm-3 ">
<%= user.firstname %> &nbsp;<%= user.lastname %>
</div>
<div class="col-sm-3 ">
<%= user.email %>
</div>


<div class="col-sm-3 ">
<%= link_to 'Approve', {:action => "approverequest", :user => user.id } %>
</div>


<div class="col-sm-3 ">
<%= link_to 'Reject', {:action => "rejectrequest", :user => user.id } %>
</div>
</div>
<%end%>
<% if @users.size == 0 %>
<em>No Joining requests are found</em>
<% end %>


</div>
Empty file modified bin/bundler
100755 → 100644
Empty file.
Empty file modified bin/byebug
100755 → 100644
Empty file.
Empty file modified bin/erubis
100755 → 100644
Empty file.
Empty file modified bin/htmldiff
100755 → 100644
Empty file.
Empty file modified bin/ldiff
100755 → 100644
Empty file.
Empty file modified bin/nokogiri
100755 → 100644
Empty file.
Empty file modified bin/rackup
100755 → 100644
Empty file.
Empty file modified bin/rdoc
100755 → 100644
Empty file.
Empty file modified bin/ri
100755 → 100644
Empty file.
Empty file modified bin/rspec
100755 → 100644
Empty file.
Empty file modified bin/sass
100755 → 100644
Empty file.
Empty file modified bin/sass-convert
100755 → 100644
Empty file.
Empty file modified bin/scss
100755 → 100644
Empty file.
Empty file modified bin/sdoc
100755 → 100644
Empty file.
Empty file modified bin/sdoc-merge
100755 → 100644
Empty file.
Empty file modified bin/sprockets
100755 → 100644
Empty file.
Empty file modified bin/thor
100755 → 100644
Empty file.
Empty file modified bin/tilt
100755 → 100644
Empty file.
Loading