Admin Slight Revamp #3364

Closed
wants to merge 44 commits into
from
@kostasnw

So what changed in short words:

  • Added rake admin task. It reads config/admin.yml and creates the users/persons it finds giving them admin privileges <--- Admin Panel --->
  • User search now works with incomplete usernames/emails (e.g. writing ko will return all users with ko in their username/email)
  • Also user search displays results in a nice readable expandable list
  • Added a link in the admin bar for Rails Admin (if on production environment)
  • Changed Correlations view to be more readable and beautiful

You can also consult our blog at: fairytailprojectteam.blogspot.gr
unfortunately it's in greek so it needs translation but you can still look at pics xD

@maxwell
diaspora* social network member

Most likely, this should be submitted as multiple pull requests, as some things are fine and dandy, and other need a bit more work before they can be pulled in.

Generally, its good to submit a pull request with the "smallest quantum of utility." That makes it wayyyyy easier to give you feedback, easier for you to write tests, and get the most stuff into master ASAP.

@maxwell
diaspora* social network member

Most likely, this should be submitted as multiple pull requests, as some things are fine and dandy, and other need a bit more work before they can be pulled in.

Generally, its good to submit a pull request with the "smallest quantum of utility." That makes it wayyyyy easier to give you feedback, easier for you to write tests, and get the most stuff into master ASAP.

@maxwell
diaspora* social network member

Also, its best to not have merge commits with diaspora/diaspora as that can be disasterous to our Git history tree.

@maxwell maxwell and 2 others commented on an outdated diff Jun 7, 2012
@@ -130,7 +130,7 @@ group :assets do
gem "asset_sync", :require => nil
end
-gem 'jquery-rails'
+gem 'jquery-rails', '>= 1.0.3'
# web
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

why?

@stevenh512
stevenh512 added a line comment Jun 9, 2012

If we're going to specify a version at all, it should probably be '>= 1.0.17' since we're using Rails Admin. It requires Jquery 1.7 and jquery_rails 1.0.17 was the first version to include 1.7. 😁

@kostasnw
kostasnw added a line comment Jun 10, 2012

i think there were problems unless i had specified that version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell commented on an outdated diff Jun 7, 2012
app/assets/stylesheets/expand.css
@@ -0,0 +1,34 @@
+#listContainer{
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

please use scss for this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell commented on an outdated diff Jun 7, 2012
app/controllers/admins_controller.rb
params[:user].delete_if {|key, value| value.blank? }
- @users = params[:user].empty? ? [] : User.where(params[:user])
+ @users = params[:user].empty? ? [] : User.where("username LIKE ? and email LIKE ?", username, email)
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

this search should be a scope in user, and most likely needs tests! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell and 1 other commented on an outdated diff Jun 7, 2012
app/controllers/admins_controller.rb
params[:user].delete_if {|key, value| value.blank? }
- @users = params[:user].empty? ? [] : User.where(params[:user])
+ @users = params[:user].empty? ? [] : User.where("username LIKE ? and email LIKE ?", username, email)
+ @users.each do |user|
+ user.attributes.each do |att|
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

not sure what this is doing?

@kostasnw
kostasnw added a line comment Jun 10, 2012

if something is not filled it will show as N/A instead of a blank. but i think I didn't manage to do it yet since this is a Model and not a Hash...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell and 1 other commented on an outdated diff Jun 7, 2012
app/views/layouts/application.html.haml
@@ -36,7 +36,7 @@
= jquery_include_tag
- unless @landing_page
- = javascript_include_tag :main, :templates
+ = javascript_include_tag :main, :templates, :tk
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

what is tk, and why is it outside of our main.js?

@kostasnw
kostasnw added a line comment Jun 10, 2012

wanted to test something forgot to take it off...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell and 1 other commented on an outdated diff Jun 7, 2012
config/database.yml
@@ -3,8 +3,6 @@ mysql: &mysql
host: "localhost"
port: 3306
username: "root"
- password: ""
-# socket: /tmp/mysql.sock
charset: utf8
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

Not sure why this is here.

@kostasnw
kostasnw added a line comment Jun 10, 2012

hmm why didn't git ignore it? i'll see to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell commented on the diff Jun 7, 2012
config/routes.rb
@@ -135,6 +135,8 @@
get :stats, :as => 'pod_stats'
get "add_invites/:invite_code_id" => 'admins#add_invites', :as => 'add_invites'
end
+ get 'admins' => 'admins#stats'
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

routes are regex so you could do a conditional ?

@kostasnw
kostasnw added a line comment Jun 10, 2012

regular expressions? sorry I'm not quite familiar with code writting

@stevenh512
stevenh512 added a line comment Jun 11, 2012

Rubular is a good place to start for a crash course in Ruby regular expressions. :)

Gives you a quick reference, an easy way to test your regex and a link to the Pickaxe if you need more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell commented on an outdated diff Jun 7, 2012
lib/tasks/addAdmin.rake
+
+ puts "making #{name}"
+ user = make_user_with_atts(attributes['name'], attributes['username'],attributes['password'])
+ puts "giving #{name} admin access"
+ flag = make_admin(user)
+ if flag
+ puts "success"
+ else
+ puts "fail"
+ end
+
+ end
+end
+
+def make_user_with_atts(name, username, password)
+ first, last = name.split
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

this looks like some copypasta of some bad code I wrote and didnt test :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell maxwell commented on an outdated diff Jun 7, 2012
lib/tasks/addAdmin.rake
@@ -0,0 +1,57 @@
+desc 'Seeds Admins'
+task :admin => :environment do
+ require 'factory_girl_rails'
+ admin_yml = YAML.load(File.open(File.join(Rails.root, 'config', 'admin.yml')))
+
+ admin_yml.each do |name, attributes|
+
+ puts "making #{name}"
@maxwell
diaspora* social network member
maxwell added a line comment Jun 7, 2012

I owe you an apology for this one, as I saw your initial post on Diaspora Dev, and didnt respond.

I am trying to depreciate as much YML as possible.

I support the 'having a rake file give people admin access' and maybe even make a user from a rake task.

However, I would much prefer it to take command line arguments, rather than read from a file.

so something like

rake create_admin[username:maxwell, ;password:foo]
or

rake upgrade_admin[username:maxwell]

(that API sucks, but you get the idea)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maxwell
diaspora* social network member

made a bunch of comments in line. Lets start there.

@travisbot

This pull request passes (merged 7d5d3c1 into a15b239).

@kostasnw kostasnw changed rake admin task to accept command line args and not read a ym…
…l. (now it's rake create_admin[username,password]
f7b4199
@travisbot

This pull request passes (merged f7b4199 into a15b239).

@maxwell
diaspora* social network member

hows it coming?

@kostasnw

i changed the small details (removed application.yml and database.yml), removed tk.js, I changed the css to scss, i made the rake admin task to load parameters from terminal (you now do "rake create_admin[foo,1234]" where foo = username and 1234 = password, i scoped the user search, i reversed the jquery-rails back to no version specified.
I still don't get how to do regex routes and how to get null attributes from user to be shown as N/A.

@Raven24
diaspora* social network member

can you maybe rebase what you have currently to stay up-to-date and update this pull request (just force-push to your branch to overwrite, github will update) so that we may have a look at what's going on, and maybe provide support if you need any more.

nsdevaraj and others added some commits Jun 5, 2012
@nsdevaraj nsdevaraj Update master 4c174df
@Raven24 Raven24 show a "post is not public" message when visitor is not logged in
and tries to access a show page of a non-public post
045df41
@fermionic fermionic strip comment text upon comment creation c1aca25
@Raven24 Raven24 use File.join when it's already there 375a1d7
@fermionic fermionic add rspec test and make fix more rails-y 4d2814f
@fermionic fermionic fix incorrect comment on RSpec text 49e0092
@Gallaecio Gallaecio Updated Galician (gl) translation. b73bfd8
@stevenh512 stevenh512 Rails.root and File.join cleanup
- `Rails.root` is a `Pathname`, so let's use `Rails.root.join`
- Clean up most of the remaining `File.join`s
dea6223
@stevenh512 stevenh512 Use https for git dependencies in the Gemfile
This is useful if your development and/or production setup is behind
a firewall and you can't use `git://`. Followup to #3358
1c20d8d
@stevenh512 stevenh512 Autoload needs a string, not a Pathname
fixes #3373
54c3a4c
@Raven24 Raven24 forgot to put new css file in precompile list [ci skip] fd699f5
@stevenh512 stevenh512 Update Rails to 3.2.6 301062d
@stevenh512 stevenh512 Fix ActiveRecord queries with nested hashes
Rails 3.2.6 doesn't like them
1ae0ea4
@stevenh512 stevenh512 Fix ActiveRecord queries - take two 5b87ca7
@stevenh512 stevenh512 Get Spork running again
Use Rails.root.join in `spec/spec_helper.rb` to help Spork find
`helper_methods.rb` and `spec_doc.rb`.
dbe207c
@stevenh512 stevenh512 Fix deprecation warning, :confirm option on links is deprecated
Use `:data => { :confirm => 'text' }` instead.
85ee00e
@jhass jhass updated 37 locale files [ci skip] 23f0c30
@Raven24 Raven24 fix startup error for integration envs e68ba47
@Raven24 Raven24 add all the colors of the rainbow, log into the same file
and throw in some formatting
9595121
@ChaosCoder ChaosCoder Removed double "the" in section "Quick Start - Step 2" c4b92f0
@Raven24 Raven24 tinker with log messages for readability 3255844
@Raven24 Raven24 cleanup session cukes e3b7a98
@Raven24 Raven24 be more specific in config, point to more info [ci skip] 7ac14f9
@maxwell maxwell fix sa mall possible xss in personImage handlebar helpers if the atta…
…cker had access to your root domain. fixes #3392
3117b4e
@movilla movilla Login with pod_name 86ca479
@maxwell maxwell limit the amount of people in a converasation to prevent hella spam 7363b2b
@Raven24 Raven24 don't open comment pane on show page, if a modifier key is pressed f85227e
@Raven24 Raven24 fix client-side validations in registration form + test 0092132
@Raven24 Raven24 tell jQuery not to expect html when deleting photos in the publisher b276328
@kostasnw kostasnw changed rake admin task 638c0d8
@travisbot

This pull request fails (merged 638c0d8 into d331a14).

@travisbot

This pull request fails (merged e46eaa9 into d331a14).

@maxwell
diaspora* social network member

You need to close this pull request, and open up several smaller new ones. Somehow some master merge comments made it into you PR, and you really should submit pull requests on feature branches. The "how to contribute" part of the wiki has some good instructions.

@kostasnw kostasnw closed this Jun 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment