faalis 1.0.0.alpha1 → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -10
- data/Rakefile +6 -2
- data/app/assets/javascripts/faalis/angular-manifest.js +3 -0
- data/app/assets/javascripts/faalis/application.js +0 -1
- data/app/assets/javascripts/faalis/dashboard/app.js +20 -6
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +5 -1
- data/app/assets/javascripts/faalis/dashboard/controllers/group.js.coffee +42 -0
- data/app/assets/javascripts/faalis/dashboard/functions.js.erb +20 -0
- data/app/assets/javascripts/faalis/dashboard/init.js +1 -1
- data/app/assets/javascripts/faalis/dashboard/lib/button.js.coffee +17 -0
- data/app/assets/javascripts/faalis/dashboard/lib/controllers.js.coffee +11 -0
- data/app/assets/javascripts/faalis/dashboard/lib/controllers/base_controller.js.coffee +14 -0
- data/app/assets/javascripts/faalis/dashboard/lib/controllers/generic_add_controller.js.coffee +33 -0
- data/app/assets/javascripts/faalis/dashboard/lib/controllers/generic_index_controller.js.coffee +85 -0
- data/app/assets/javascripts/faalis/dashboard/lib/fields/base.js.coffee +6 -0
- data/app/assets/javascripts/faalis/dashboard/lib/fields/has_many_field.js.coffee +4 -0
- data/app/assets/javascripts/faalis/dashboard/lib/fields/string_field.js.coffee +2 -0
- data/app/assets/javascripts/faalis/dashboard/lib/resource.js.coffee +147 -0
- data/app/assets/javascripts/faalis/dashboard/modules/auth/auth.js +5 -3
- data/app/assets/javascripts/faalis/dashboard/modules/auth/profile.js +6 -5
- data/app/assets/javascripts/faalis/dashboard/modules/auth/user.js +12 -10
- data/app/assets/javascripts/faalis/dashboard/modules/conversations.js +2 -1
- data/app/assets/javascripts/faalis/dashboard/modules/fields/#image.js# +43 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/date.js +51 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/datetime.js +26 -15
- data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +3 -1
- data/app/assets/javascripts/faalis/dashboard/modules/fields/file.js +43 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/image.js +33 -46
- data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +7 -4
- data/app/assets/javascripts/faalis/dashboard/modules/fields/tag.js +5 -11
- data/app/assets/javascripts/faalis/dashboard/modules/fields/time.js +34 -122
- data/app/assets/javascripts/faalis/dashboard/modules/logs.js +5 -4
- data/app/assets/javascripts/faalis/dashboard/modules/permissions.js.coffee +38 -0
- data/app/assets/javascripts/faalis/dashboard/resources/group_resource.js.coffee +8 -0
- data/app/assets/javascripts/faalis/dashboard/resources/permission_resource.js.coffee +6 -0
- data/app/assets/javascripts/faalis/dashboard/services/api.js.coffee +73 -0
- data/app/assets/javascripts/faalis/dashboard/services/resource_factory.js.coffee +48 -0
- data/app/assets/javascripts/faalis/dashboard/services/user.js.coffee +4 -0
- data/app/assets/javascripts/faalis/dashboard/variables.js.erb +5 -0
- data/app/assets/javascripts/faalis/{locales → locale}/en.json +0 -0
- data/app/assets/javascripts/faalis/{locales → locale}/fa.json +0 -0
- data/app/assets/javascripts/faalis/{locales → locale}/translations.fa.js +0 -0
- data/app/controllers/faalis/api/v1/groups_controller.rb +53 -57
- data/app/controllers/faalis/api/v1/permissions_controller.rb +29 -12
- data/app/controllers/faalis/api_controller.rb +19 -12
- data/app/controllers/faalis/application_controller.rb +8 -7
- data/app/controllers/faalis/dashboard_controller.rb +5 -11
- data/app/models/faalis/{user → concerns/user}/auth_definitions.rb +6 -1
- data/app/models/faalis/{user → concerns/user}/mongoid_fields.rb +8 -2
- data/app/models/faalis/concerns/user/permission.rb +24 -0
- data/app/models/faalis/concerns/user/user_roles.rb +20 -0
- data/app/models/faalis/group.rb +13 -15
- data/app/models/faalis/permission.rb +15 -1
- data/app/models/faalis/user.rb +44 -20
- data/app/policies/faalis/admin_only_policy.rb +66 -0
- data/app/policies/faalis/application_policy.rb +40 -0
- data/app/policies/faalis/group_policy.rb +8 -0
- data/app/policies/faalis/user_policy.rb +9 -0
- data/app/views/{angularjs_templates → angular}/auth/groups/details.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/groups/index.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/groups/new.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/index.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/profile/edit.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/users/details.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/users/index.html +0 -0
- data/app/views/{angularjs_templates → angular}/auth/users/new.html +0 -0
- data/app/views/{angularjs_templates → angular}/conversations/details.html +0 -0
- data/app/views/{angularjs_templates → angular}/conversations/index.html +0 -0
- data/app/views/{angularjs_templates → angular}/conversations/new.html +0 -0
- data/app/views/{angularjs_templates → angular}/conversations/show.html +0 -0
- data/app/views/{angularjs_templates → angular}/conversations/show_details.html +0 -0
- data/app/views/angular/faalis/views/generic_add_view.html.slim +5 -0
- data/app/views/{angularjs_templates → angular}/fields/boolean/boolean.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/control-combo/control-list.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/datetime/datetime.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/datetime/time.html +0 -0
- data/app/views/angular/fields/file/file.html.slim +0 -0
- data/app/views/{angularjs_templates → angular}/fields/float/float.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/image/image.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/integer/integer.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/relation/relation.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/string/string.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/tag/tag.html +0 -0
- data/app/views/{angularjs_templates → angular}/fields/text/text.html +0 -0
- data/app/views/{angularjs_templates → angular}/filter/index.html +0 -0
- data/app/views/{angularjs_templates → angular}/index.html +0 -0
- data/app/views/{angularjs_templates → angular}/locale/fa.po +0 -0
- data/app/views/{angularjs_templates → angular}/locale/templates.pot +0 -0
- data/app/views/{angularjs_templates → angular}/logs/index.html +0 -0
- data/app/views/angular/modules.html +0 -0
- data/app/views/{angularjs_templates → angular}/nav.html.erb +0 -0
- data/app/views/faalis/api/v1/groups/index.json.jbuilder +1 -1
- data/app/views/faalis/api/v1/permissions/index.json.jbuilder +1 -1
- data/app/views/faalis/dashboard/index.html.erb +1 -1
- data/app/views/layouts/faalis/application.html.erb +1 -1
- data/config/routes.rb +1 -7
- data/config/spring.rb +1 -0
- data/db/migrate/20131013091000_devise_create_faalis_users.rb +4 -4
- data/db/migrate/20131020124701_create_faalis_groups.rb +3 -0
- data/db/migrate/20131021170923_create_faalis_permissions.rb +2 -0
- data/db/seeds.rb +15 -13
- data/lib/faalis.rb +2 -2
- data/lib/faalis/concerns/authorizable.rb +1 -0
- data/lib/faalis/engine.rb +15 -16
- data/lib/faalis/{extensions.rb → extension.rb} +1 -1
- data/lib/faalis/{extensions → extension}/base.rb +0 -0
- data/lib/faalis/fake_assets.rb +2 -0
- data/lib/faalis/generators/concerns.rb +1 -1
- data/lib/faalis/generators/concerns/angular.rb +1 -1
- data/lib/faalis/generators/concerns/bulk.rb +1 -2
- data/lib/faalis/generators/concerns/input_file.rb +49 -0
- data/lib/faalis/generators/concerns/resource_fields.rb +4 -0
- data/lib/faalis/generators/concerns/tabs.rb +1 -1
- data/lib/faalis/generators/dashboard_scaffold.rb +3 -1
- data/lib/faalis/i18n.rb +1 -0
- data/lib/faalis/route.rb +26 -9
- data/lib/faalis/version.rb +1 -1
- data/lib/faalis_application.rb +442 -0
- data/lib/generators/faalis/install_generator.rb +4 -2
- data/lib/generators/faalis/js/list_view_generator.rb +3 -22
- data/lib/generators/faalis/scaffold_generator.rb +7 -10
- data/lib/generators/faalis/templates/README +0 -7
- data/lib/generators/faalis/templates/angularjs/module.js.erb +4 -1
- data/lib/generators/faalis/templates/api/controller.rb.erb +18 -21
- data/lib/generators/faalis/templates/application.js +14 -1
- data/lib/generators/faalis/templates/faalis.rb +3 -1
- data/lib/generators/faalis/templates/i18n/Gruntfile.js.erb +2 -2
- data/lib/generators/faalis/templates/js/list_view/partials/add_controller.js.erb +3 -3
- data/lib/generators/faalis/views_generator.rb +1 -1
- data/lib/tasks/docs.rake +6 -0
- data/lib/tasks/faalis_tasks.rake +1 -0
- data/lib/tasks/grunt/Gruntfile.js +3 -3
- data/spec/dummy/app/controllers/api_controller.rb +5 -0
- data/spec/dummy/config/initializers/faalis.rb +3 -3
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150121060012_create_application_models.model_discovery_engine.rb +10 -0
- data/spec/dummy/db/schema.rb +71 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +544 -0
- data/spec/dummy/log/test.log +12354 -0
- data/spec/factories/faalis/groups.rb +31 -0
- data/spec/factories/faalis/permissions.rb +16 -0
- data/spec/factories/faalis/users.rb +23 -0
- data/spec/models/faalis/group_spec.rb +32 -0
- data/spec/models/faalis/permission_spec.rb +15 -0
- data/spec/models/faalis/user_spec.rb +100 -0
- data/spec/policies/faalis/admin_only_policy_spec.rb +39 -0
- data/spec/policies/faalis/application_policy_spec.rb +49 -0
- data/spec/spec_helper.rb +26 -5
- data/spec/support/factory_girl.rb +3 -0
- metadata +225 -102
- data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +0 -155
- data/app/assets/javascripts/faalis/dashboard/modules/permissions.js +0 -52
- data/app/controllers/faalis/#api_controller.rb# +0 -51
- data/app/controllers/faalis/#dashboard_controller.rb# +0 -65
- data/app/models/ability.rb +0 -40
- data/app/models/faalis/user/permission.rb +0 -21
- data/app/views/angularjs_templates/modules.html +0 -17
- data/db/migrate/20140617124019_faalis_groups_users.rb +0 -4
- data/lib/faalis/generators/concerns/json_input.rb +0 -41
- data/lib/faalis/generators/fields/#relation.rb# +0 -61
- data/lib/faalis/patches/models.rb +0 -7
@@ -1,155 +0,0 @@
|
|
1
|
-
var Group = angular.module("Group", ["ListView", "Errors"]);
|
2
|
-
|
3
|
-
Group.config(["$routeProvider", function($routeProvider){
|
4
|
-
$routeProvider.
|
5
|
-
when("/auth/groups",{
|
6
|
-
templateUrl: template("auth/groups/index"),
|
7
|
-
controller: "GroupsController"
|
8
|
-
}).
|
9
|
-
when("/auth/groups/new",{
|
10
|
-
templateUrl: template("auth/groups/new"),
|
11
|
-
controller: "AddGroupController"
|
12
|
-
}).
|
13
|
-
when("/auth/groups/:id/edit",{
|
14
|
-
templateUrl: template("auth/groups/new"),
|
15
|
-
controller: "AddGroupController"
|
16
|
-
});
|
17
|
-
|
18
|
-
}]);
|
19
|
-
|
20
|
-
Group.controller("GroupsController", ["$scope", "gettext", "Restangular", "catch_error", function($scope, gettext, API, catch_error){
|
21
|
-
$scope.details_template = template("auth/groups/details");
|
22
|
-
|
23
|
-
$scope.buttons = [
|
24
|
-
{
|
25
|
-
title: gettext("new"),
|
26
|
-
icon: "fa fa-plus",
|
27
|
-
classes: "btn tiny green",
|
28
|
-
route: "#/auth/groups/new"
|
29
|
-
|
30
|
-
}
|
31
|
-
];
|
32
|
-
|
33
|
-
$scope.on_delete = function(groups){
|
34
|
-
|
35
|
-
var query = [];
|
36
|
-
groups.forEach(function(group){
|
37
|
-
query.push(group.id);
|
38
|
-
});
|
39
|
-
|
40
|
-
API.all("groups").customDELETE(query.join(","))
|
41
|
-
.then(function(data) {
|
42
|
-
|
43
|
-
$scope.groups = _.filter($scope.groups, function(x){
|
44
|
-
return !(query.indexOf(x.id) != -1);
|
45
|
-
});
|
46
|
-
success_message(data.msg);
|
47
|
-
})
|
48
|
-
.catch(catch_error);
|
49
|
-
|
50
|
-
};
|
51
|
-
|
52
|
-
|
53
|
-
API.all("groups").getList()
|
54
|
-
.then(function(data){
|
55
|
-
$scope.groups = data;
|
56
|
-
})
|
57
|
-
.catch(catch_error);
|
58
|
-
|
59
|
-
}]);
|
60
|
-
|
61
|
-
Group.controller("AddGroupController", ["Restangular", "$scope", "$location", "$routeParams", "gettext", "catch_error", function(API, $scope, $location, $routeParams, gettext, catch_error){
|
62
|
-
|
63
|
-
$scope.selected_perms = [];
|
64
|
-
$scope.permissions = [];
|
65
|
-
$scope.editing = false;
|
66
|
-
|
67
|
-
|
68
|
-
$scope.$on("update_perms", function(event) {
|
69
|
-
var sel_perms = [];
|
70
|
-
event.targetScope.selected_perms.forEach(function(perm){
|
71
|
-
|
72
|
-
var tmpobj = _.find(event.targetScope.permissions, function(x) {
|
73
|
-
return perm.name == x.name;
|
74
|
-
});
|
75
|
-
|
76
|
-
if ( tmpobj ) {
|
77
|
-
event.targetScope.select_permission(tmpobj);
|
78
|
-
}
|
79
|
-
});
|
80
|
-
|
81
|
-
});
|
82
|
-
|
83
|
-
$scope.obj_id = null;
|
84
|
-
|
85
|
-
if("id" in $routeParams){
|
86
|
-
$scope.obj_id = $routeParams.id;
|
87
|
-
$scope.editing = true;
|
88
|
-
var obj = API.one("groups", $scope.obj_id).get()
|
89
|
-
.then(function(data) {
|
90
|
-
$scope.new_name = data.name;
|
91
|
-
$scope.selected_perms = data.permissions;
|
92
|
-
$scope.$emit("update_perms");
|
93
|
-
})
|
94
|
-
.catch(catch_error);
|
95
|
-
}
|
96
|
-
|
97
|
-
API.all('permissions').getList()
|
98
|
-
.then(function(data){
|
99
|
-
$scope.permissions = data;
|
100
|
-
$scope.$emit("update_perms");
|
101
|
-
})
|
102
|
-
.catch(catch_error);
|
103
|
-
|
104
|
-
|
105
|
-
$scope.select_permission = function(perm){
|
106
|
-
if( "is_selected" in perm ){
|
107
|
-
perm.is_selected = ! perm.is_selected;
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
perm.is_selected = true;
|
111
|
-
};
|
112
|
-
|
113
|
-
$scope.is_selected = function(perm){
|
114
|
-
if( "is_selected" in perm ){
|
115
|
-
return perm.is_selected;
|
116
|
-
}
|
117
|
-
return false;
|
118
|
-
};
|
119
|
-
|
120
|
-
$scope.cancel = function(){
|
121
|
-
$(".form input").val("");
|
122
|
-
for(var i = 0; i < $scope.permissions.length;i++) {
|
123
|
-
$scope.permissions[i].is_selected = false;
|
124
|
-
}
|
125
|
-
};
|
126
|
-
|
127
|
-
$scope.save = function(){
|
128
|
-
var permissions = [];
|
129
|
-
|
130
|
-
for(var i = 0; i < $scope.permissions.length;i++) {
|
131
|
-
if ($scope.permissions[i].is_selected){
|
132
|
-
permissions.push($scope.permissions[i].name);
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
var group = {name: $scope.new_name,
|
137
|
-
permissions: permissions};
|
138
|
-
if ($scope.obj_id) {
|
139
|
-
API.one("groups", $scope.obj_id).patch(group)
|
140
|
-
.then(function(){
|
141
|
-
success_message(gettext("Group updated successfully."));
|
142
|
-
$location.path("/auth/groups");
|
143
|
-
})
|
144
|
-
.catch(catch_error);
|
145
|
-
}
|
146
|
-
else {
|
147
|
-
API.all("groups").post(group).then(function(){
|
148
|
-
success_message(gettext("Group created successfully."));
|
149
|
-
$location.path("/auth/groups");
|
150
|
-
|
151
|
-
}).catch(catch_error);
|
152
|
-
}
|
153
|
-
|
154
|
-
};
|
155
|
-
}]);
|
@@ -1,52 +0,0 @@
|
|
1
|
-
var Perm = angular.module("Permissions", []);
|
2
|
-
|
3
|
-
Perm.factory('UserPermissions', ["$rootScope", function ($rootScope) {
|
4
|
-
var permissionList;
|
5
|
-
return {
|
6
|
-
set_permissions: function(permissions) {
|
7
|
-
PERMISSIONS = permissions;
|
8
|
-
$rootScope.$broadcast('permissions_changed');
|
9
|
-
},
|
10
|
-
|
11
|
-
/*
|
12
|
-
* Check if user has specific permission on an object
|
13
|
-
*/
|
14
|
-
can: function(action, model) {
|
15
|
-
if (model in PERMISSIONS) {
|
16
|
-
if (_.indexOf(PERMISSIONS[model], action) !== -1) {
|
17
|
-
//console.log("User can " + action + " " + model);
|
18
|
-
return true;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
//console.log("User can't " + action + " " + model);
|
22
|
-
return false;
|
23
|
-
|
24
|
-
},
|
25
|
-
/*
|
26
|
-
* Check if user has specific permission on an object
|
27
|
-
*/
|
28
|
-
can_not: function(action, model) {
|
29
|
-
return ! this.can(action,model);
|
30
|
-
}
|
31
|
-
|
32
|
-
};
|
33
|
-
}]);
|
34
|
-
|
35
|
-
Perm.directive('ifUser', ["UserPermissions", function(User) {
|
36
|
-
|
37
|
-
function link(scope, element, attrs) {
|
38
|
-
if (scope.value === true) {
|
39
|
-
element.show();
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
element.hide();
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return {
|
46
|
-
restrict: "A",
|
47
|
-
scope: {
|
48
|
-
value: "=ifUser"
|
49
|
-
},
|
50
|
-
link: link
|
51
|
-
};
|
52
|
-
}]);
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
# Faalis - Basic website skel engine
|
3
|
-
# Copyright (C) 2012-2013 Yellowen
|
4
|
-
#
|
5
|
-
# This program is free software; you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation; either version 2 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public License along
|
16
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
-
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
-
# -----------------------------------------------------------------------------
|
19
|
-
require_dependency "faalis/api_controller"
|
20
|
-
|
21
|
-
|
22
|
-
class Faalis::APIController < Faalis::ApplicationController
|
23
|
-
respond_to :json
|
24
|
-
|
25
|
-
before_filter :authenticate_user!
|
26
|
-
|
27
|
-
protect_from_forgery
|
28
|
-
|
29
|
-
after_filter :set_csrf_cookie_for_ng
|
30
|
-
|
31
|
-
def set_csrf_cookie_for_ng
|
32
|
-
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
33
|
-
end
|
34
|
-
|
35
|
-
rescue_from CanCan::AccessDenied do |exception|
|
36
|
-
|
37
|
-
render :status => 403, :json => {
|
38
|
-
:error => _("You don't have access to this page"),
|
39
|
-
:orig_msg => exception.message,
|
40
|
-
:action => exception.action,
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
|
46
|
-
def verified_request?
|
47
|
-
super || form_authenticity_token == request.headers['X-XSRF-TOKEN']
|
48
|
-
end
|
49
|
-
|
50
|
-
:
|
51
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require_dependency "faalis/application_controller"
|
2
|
-
|
3
|
-
|
4
|
-
module Faalis
|
5
|
-
class DashboardController < ApplicationController
|
6
|
-
|
7
|
-
include Faalis::Dashboard::Controller
|
8
|
-
|
9
|
-
layout "faalis/dashboard"
|
10
|
-
before_filter :authenticate_user!, :only => [:modules, :index]
|
11
|
-
|
12
|
-
respond_to :json, :html
|
13
|
-
|
14
|
-
def jstemplate
|
15
|
-
if user_signed_in?
|
16
|
-
render :template => "angularjs_templates/#{params[:path]}", :layout => nil
|
17
|
-
else
|
18
|
-
render :login_required_page
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def index
|
23
|
-
if params.include? :signin
|
24
|
-
redirect_to dashboard_path
|
25
|
-
end
|
26
|
-
@jstemplates_path = "/templates"
|
27
|
-
end
|
28
|
-
|
29
|
-
def modules
|
30
|
-
dashboard_modules = []
|
31
|
-
|
32
|
-
Faalis::Engine.dashboard_modules.each do |module_name, attrs|
|
33
|
-
if not attrs.include? :title
|
34
|
-
attrs[:title] = _(module_name.to_s)
|
35
|
-
end
|
36
|
-
|
37
|
-
if not attrs.include? :resource
|
38
|
-
attrs[:resource] = module_name.to_s
|
39
|
-
end
|
40
|
-
|
41
|
-
# If class did not given by user in settings
|
42
|
-
# Faalis tries to guess the class name
|
43
|
-
if not attrs.include? :model
|
44
|
-
begin
|
45
|
-
klass = attrs[:resource].camelize.constantize
|
46
|
-
|
47
|
-
if klass.respond_to? :possible_permissions
|
48
|
-
attrs[:model] = attrs[:resource].camelize
|
49
|
-
else
|
50
|
-
attrs[:model] = ""
|
51
|
-
end
|
52
|
-
|
53
|
-
rescue NameError
|
54
|
-
attrs[:model] = ""
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
dashboard_modules << attrs
|
59
|
-
end
|
60
|
-
dashboard_modules = {:modules => dashboard_modules}
|
61
|
-
respond_with dashboard_modules
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
data/app/models/ability.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
class Ability
|
2
|
-
include CanCan::Ability
|
3
|
-
|
4
|
-
def initialize(user)
|
5
|
-
# Define abilities for the passed in user here. For example:
|
6
|
-
#
|
7
|
-
# user ||= User.new # guest user (not logged in)
|
8
|
-
# if user.admin?
|
9
|
-
# can :manage, :all
|
10
|
-
# else
|
11
|
-
# can :read, :all
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# The first argument to `can` is the action you are giving the user
|
15
|
-
# permission to do.
|
16
|
-
# If you pass :manage it will apply to every action. Other common actions
|
17
|
-
# here are :read, :create, :update and :destroy.
|
18
|
-
#
|
19
|
-
# The second argument is the resource the user can perform the action on.
|
20
|
-
# If you pass :all it will apply to every resource. Otherwise pass a Ruby
|
21
|
-
# class of the resource.
|
22
|
-
#
|
23
|
-
# The third argument is an optional hash of conditions to further filter the
|
24
|
-
# objects.
|
25
|
-
# For example, here the user can only update published articles.
|
26
|
-
#
|
27
|
-
# can :update, Article, :published => true
|
28
|
-
#
|
29
|
-
# See the wiki for details:
|
30
|
-
# https://github.com/ryanb/cancan/wiki/Defining-Abilities
|
31
|
-
|
32
|
-
# IMPORTANT: Remove this snippet with more suitable one
|
33
|
-
# TODO: Remove this snippet with more suitable one
|
34
|
-
user.groups.each do |group|
|
35
|
-
group.permissions.each do |permission|
|
36
|
-
can permission.permission_type.to_sym, permission.model.constantize
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Faalis
|
2
|
-
# This concern contains all the permission related methods
|
3
|
-
# to use within `Faalis::User`
|
4
|
-
module User::Permission
|
5
|
-
|
6
|
-
# Return all the user permissions
|
7
|
-
def permissions
|
8
|
-
perms = []
|
9
|
-
|
10
|
-
groups.each do |group|
|
11
|
-
group.permissions.each do |perm|
|
12
|
-
# It's obvious isn't it ?
|
13
|
-
yield perm if block_given?
|
14
|
-
perms << perm
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
perms
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<ul data-ng-controller="ModulesController as controller">
|
2
|
-
|
3
|
-
<li ng-click="controller.on_click('/')"><p><i class="fa fa-dashboard"></i> <span translate>Dashboard</span></p></li>
|
4
|
-
|
5
|
-
<li data-ng-repeat="module in controller.modules">
|
6
|
-
<p ng-click="controller.view_menu(module)"><i class="{{ module.icon }}"></i> <span translate>{{ module.title }}</span></p>
|
7
|
-
<ul class="submenu slide" ng-if="module.show_menu">
|
8
|
-
<li ng-repeat="menu_item in module.menu_items" ng-click="controller.on_click(menu_item.url)"><span>{{ menu_item.title }}</span></li>
|
9
|
-
</ul>
|
10
|
-
</li>
|
11
|
-
|
12
|
-
</ul>
|
13
|
-
|
14
|
-
<div class="brand">
|
15
|
-
<h1 translate><%= Faalis::Engine.site_title %></h1>
|
16
|
-
<span translate></span>
|
17
|
-
</div>
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
|
4
|
-
module Faalis
|
5
|
-
module Generators
|
6
|
-
module Concerns
|
7
|
-
# This module Provide an argument for generator which
|
8
|
-
# is needed by other `Concerns`.
|
9
|
-
# Each Concern will have its own entry in scaffold json
|
10
|
-
# file. For documentation on each entry checkout its concern class
|
11
|
-
module JsonInput
|
12
|
-
|
13
|
-
def self.included(base)
|
14
|
-
# Name of the resource to create.
|
15
|
-
base.argument :jsonfile , :type => :string, :required => true
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
# Read the json file and returns its raw data
|
21
|
-
def json_file_data
|
22
|
-
path = File.expand_path(jsonfile)
|
23
|
-
File.read(path)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Return the hash related to json structure from cache or by
|
27
|
-
# reading file.
|
28
|
-
def resource_data
|
29
|
-
if @data
|
30
|
-
@data
|
31
|
-
else
|
32
|
-
@data = JSON.parse(json_file_data)
|
33
|
-
@data
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|