From 61b69201b1fc87c65ef03a0f291e6a2182e8eba9 Mon Sep 17 00:00:00 2001 From: rchada Date: Sun, 21 Feb 2016 15:09:37 -0500 Subject: [PATCH] Updates to admin --- admin.rb | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/admin.rb b/admin.rb index c751799..e094517 100644 --- a/admin.rb +++ b/admin.rb @@ -1,31 +1,43 @@ require 'pry' -#you run a site that offers a matching service between vendors selling laptops and customers -#..looking to purchase; you charge a fee to be listed as a vendor +#you run a site that offers a matching service between vendors selling laptops and customers +#..looking to purchase; you charge a fee to be listed as a vendor #your site's users must sign in and if they are an admin they are able to make changes to the site ####################################################### #write a function "user_permission" that accepts four parameters: signed_in, admin, paid, and canceled +def user_permission(signed_in, admin, paid, canceled) #if the user doesn't pay their bills or has canceled a deal, show "go away!" + if paid == "no" or canceled == "yes" + puts("go away") #if the user is signed in and they are an admin, show "you can see see and change all the pages!" + elsif signed_in == "yes" and admin == "yes" + puts("you can see and change all the pages!") #if you user is signed in but they are not an admin, show "you can see all the pages!" + elsif signed_in == "yes" and admin == "no" + puts("you can see all the pages!") #if the user is not signed in, show "you can't see any of the pages, please sign in!" + elsif signed_in == "no" + puts("you can't see any of the pages, please sign in!") + end +end #ask the user if they pay their bills (yes/no) - +puts("Have you paid your bills? (yes/no)") #store their answer in a variable - +user_paid = gets.strip.downcase #ask the user if they have canceled a deal (yes/no) - +puts("Have you canceled a deal? (yes/no)") #store their answer in a variable - +user_canceled = gets.strip.downcase #ask the user if they are an admin (yes/no) - +puts("Are you an admin? (yes/no)") #store their answer in a variable - +user_admin = gets.strip.downcase #ask the user if they are signed in (yes/no) - +puts("Are you signed in? (yes/no)") #store their answer in a variable - -#call the function +user_signed_in = gets.strip.downcase +#call the function +user_permission(user_signed_in, user_admin, user_paid, user_canceled)