Created
November 29, 2012 13:57
-
-
Save nicomen/4169252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Bazaar-Admin/bazaar-admin.conf b/Bazaar-Admin/bazaar-admin.conf | |
index 4d8f64f..2bf56fa 100644 | |
--- a/Bazaar-Admin/bazaar-admin.conf | |
+++ b/Bazaar-Admin/bazaar-admin.conf | |
@@ -2,4 +2,23 @@ | |
abuse_mail => '[email protected]', | |
default_lang => 'en', | |
name => 'Cell Bazaar Administration', | |
+ | |
+ routes => { | |
+ admin => { | |
+ 'logout' => 'Log out', | |
+ }, | |
+ moderator => { | |
+ 'moderate' => 'Start moderation', | |
+ }, | |
+ supervisor => { | |
+ 'extra' => 'Extra control', | |
+ 'items' => 'Item admin', | |
+ 'users' => 'User admin', | |
+ }, | |
+ superadmin => { | |
+ 'profanity' => 'Profanity filter', | |
+ 'categories' => 'Category editor', | |
+ 'admins' => 'Admin admin', | |
+ } | |
+ } | |
} | |
diff --git a/Bazaar-Admin/lib/Bazaar/Admin.pm b/Bazaar-Admin/lib/Bazaar/Admin.pm | |
index 0e0b719..706be5d 100644 | |
--- a/Bazaar-Admin/lib/Bazaar/Admin.pm | |
+++ b/Bazaar-Admin/lib/Bazaar/Admin.pm | |
@@ -94,11 +94,21 @@ sub setup_routes { | |
my $sup = $user_bridge->('is_supervisor'); | |
my $adm = $user_bridge->('is_superadmin'); | |
+ my $routes = $app->config->{routes}; | |
+ foreach my $level (keys %{$routes}) { | |
+ foreach my $path (keys %{$routes->{$level}}) { | |
+ # config format: level => { 'path' => 'menu name', ... } | |
+ # Example: GET /foo/bar checks if user has a level that contains the /foo path, then calls Foo->new->bar() | |
+ # GET /foo checks if user has a level that contains the /foo path, then calls Foo->new->index(); | |
+ $user_bridge->("is_$level")->route("/$path/:action")->to(controller => $path, action => 'index'); | |
+ } | |
+ } | |
+ | |
$r->get('/login')->to('user#login'); | |
$r->post('/login')->to('user#do_login'); | |
$a->get('/')->to('meta#index'); | |
- $a->get('/moderate')->to('moderate#start'); | |
+# $a->get('/moderate')->to('moderate#start'); | |
} | |
1; | |
diff --git a/Bazaar-Admin/lib/Bazaar/Admin/Moderate.pm b/Bazaar-Admin/lib/Bazaar/Admin/Moderate.pm | |
index fa2e9fe..2262b72 100644 | |
--- a/Bazaar-Admin/lib/Bazaar/Admin/Moderate.pm | |
+++ b/Bazaar-Admin/lib/Bazaar/Admin/Moderate.pm | |
@@ -1,7 +1,7 @@ | |
package Bazaar::Admin::Moderate; | |
use Mojo::Base 'Mojolicious::Controller'; | |
-sub start { | |
+sub index { | |
my $self = shift; | |
my $pending = $self->db->resultset('Item')->with_status('pending')->first; | |
return $self->render('moderate/empty') unless $pending; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment