sunrise-cms 0.7.0.rc2 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -17
- data/app/assets/stylesheets/sunrise/main.css +1 -1
- data/app/controllers/sunrise/manager_controller.rb +4 -7
- data/app/controllers/sunrise/settings_controller.rb +1 -1
- data/app/views/layouts/sunrise/application.html.erb +1 -1
- data/app/views/sunrise/manager/_form.html.erb +1 -1
- data/app/views/sunrise/shared/_filter.html.erb +3 -3
- data/app/views/sunrise/shared/_panel.html.erb +2 -2
- data/app/views/sunrise/shared/_toolbar.html.erb +1 -1
- data/config/routes.rb +14 -15
- data/lib/generators/sunrise/templates/config/active_record/sunrise.rb +11 -8
- data/lib/generators/sunrise/templates/config/mongoid/sunrise.rb +9 -6
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_navigation.rb +8 -9
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_page.rb +4 -4
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_structure.rb +8 -8
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb +14 -14
- data/lib/generators/sunrise/templates/uploaders/avatar_uploader.rb +1 -1
- data/lib/sunrise/abstract_model.rb +29 -27
- data/lib/sunrise/config/export.rb +26 -0
- data/lib/sunrise/config/{edit.rb → form.rb} +1 -1
- data/lib/sunrise/config/{list.rb → index.rb} +1 -1
- data/lib/sunrise/config/model.rb +23 -12
- data/lib/sunrise/config/navigation.rb +33 -11
- data/lib/sunrise/config/page_presenter.rb +31 -0
- data/lib/sunrise/config.rb +15 -10
- data/lib/sunrise/engine.rb +0 -1
- data/lib/sunrise/models/structure.rb +7 -7
- data/lib/sunrise/utils.rb +0 -1
- data/lib/sunrise/version.rb +1 -1
- data/spec/controllers/sunrise/settings_controller_spec.rb +2 -2
- data/spec/dummy/app/{models/sunrise → sunrise}/sunrise_post.rb +3 -3
- data/spec/dummy/config/application.rb +2 -10
- data/spec/dummy/config/environments/development.rb +3 -0
- data/spec/dummy/config/environments/production.rb +6 -0
- data/spec/dummy/config/environments/test.rb +5 -3
- data/spec/dummy/db/schema.rb +90 -0
- data/spec/models/avatar_spec.rb +1 -1
- data/spec/models/sunrise/abstract_model_spec.rb +5 -8
- data/spec/requests/manager/default/edit_spec.rb +1 -1
- data/spec/requests/manager/default/new_spec.rb +1 -1
- data/spec/requests/manager/default/update_spec.rb +3 -3
- data/spec/requests/manager/many/index_spec.rb +2 -1
- data/spec/requests/manager/many/new_spec.rb +1 -1
- data/spec/spec_helper.rb +18 -0
- data/spec/sunrise_spec.rb +2 -2
- metadata +10 -405
- data/app/controllers/sunrise/shared_controller.rb +0 -13
- data/app/views/sunrise/shared/services.json.jbuilder +0 -6
- data/lib/sunrise/utils/mysql.rb +0 -35
- data/spec/controllers/sunrise/shared_controller_spec.rb +0 -32
- data/spec/dummy/log/test.log +0 -22584
- data/spec/dummy/public/uploads/avatar/content_rails.png +0 -0
- data/spec/dummy/public/uploads/avatar/rails.png +0 -0
- data/spec/dummy/public/uploads/avatar/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814500-44499-6278/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814500-44499-6278/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814500-44499-6278/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814501-44499-0716/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814501-44499-0716/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814501-44499-0716/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814501-44499-6498/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814501-44499-6498/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814501-44499-6498/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814502-44499-9048/silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397814502-44499-9048/small_silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397814502-44499-9048/thumb_silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397814509-44499-4712/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814511-44499-6511/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814514-44499-0946/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814515-44499-4275/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814516-44499-7258/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814743-45062-5613/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814743-45062-5613/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814743-45062-5613/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814744-45062-2352/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814744-45062-2352/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814744-45062-2352/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814744-45062-7990/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814744-45062-7990/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814744-45062-7990/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814745-45062-4632/silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397814745-45062-4632/small_silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397814745-45062-4632/thumb_silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397814752-45062-3620/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814754-45062-7554/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814757-45062-6575/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814758-45062-2473/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397814758-45062-7698/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815061-45673-4098/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815061-45673-4098/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815061-45673-4098/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815062-45673-5873/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815062-45673-5873/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815062-45673-5873/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815062-45673-9908/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815062-45673-9908/small_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815062-45673-9908/thumb_rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815063-45673-6362/silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397815063-45673-6362/small_silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397815063-45673-6362/thumb_silicon_valley.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1397815070-45673-9261/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815072-45673-2350/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815075-45673-3163/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815076-45673-3745/rails.png +0 -0
- data/spec/dummy/public/uploads/tmp/1397815077-45673-2689/rails.png +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/025a845bfc99eb99aa9690545d024974 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/02ca6949ca99936393e2992467409faf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/03bae0b322a9c8706915fdb4f8d50961 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/06632caa2dd14ba28b138446bd3d807a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/06a86d61c2e57fad1cee30584df6f969 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/07d036bf808a7ace22ce3b32701a2867 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0cc8e44f8b692c44ef509fd2d7f38941 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0d7fd69f7cbd03f1617b280bfb33677e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0e7270936d642e566d747ab335c44ec2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0f382880a507fbcedb3a83727f118f84 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0fab3bb8b5212da52c8b7e0ae428b22a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/12bbe81ebeeacdf11820f57a821789ff +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/146ce2f3522fd98d4a8a1501f16c7092 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/172c139e25cc08516d5a8c72c777dd4d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/18b64b11b8b00cc21a396da25a5ff156 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/197d8d604ec08a638b656e053944b734 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1bdb903463fe67323dbadb0f78337c70 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1beea1617441e02d76649f4b799aedac +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/20f8ac265bd1f0c57067c7a4b5c8f119 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/212fc15df4fd708ebdef5bd3be2191c1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/256dcb01e7f35659d770584fd71a85d2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2a6ef2448bbff5c2c3c70c141f744cf5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2dedb8177c20286c4259c1d58c5646cc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/33b9cc34fd627b9c81e63eb0faf06efb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/33bd898bccf5b0821d1d3ffa02e9d1b6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/350390c7e44df7d038254cff29468e2d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3633276e08728ac0cfea5659b4f8b516 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/37b103f4623089af1456b90830fe941c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/392239d689265304b5fe68912a8f2383 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3c396fbac68d9fb827a0f4c9d8cae3b6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/43ad0cf2497efae7114ac03a314706c5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/46e447bca92498433b2a3114106389a9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/47395ef44102932b2b9fe17a46c16601 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4c1c0c6c54ed879c4a5489eadd3a772c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4ca01587005a9b895bca383881bec87d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4cffdba2a7aac80c1765e060b152b382 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/54d68ac9b230a01a37ef415779a748da +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/55b923cfea92fd264597042a44303f0c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/56d4d696f46e9a63d0a42e11556bce11 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/56e5bd2f3c94d7a9d0da7c4e05c7ad78 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5807e61754ed8b16702f6ad7ba34d439 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5a44970074ecbfeae2cc9798ed7da7aa +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5ab8f53cba6a8bdf2c6d671491c397ce +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5e27babe25470126fbc4635dc9fe9a6a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6056bd921f3a4b6e437dab030d7fef90 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/61533733f5f9ec09571d2d5c45d5ab47 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/68c52f388e9c2401252c0bedf6247c8c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6a1e72555b75237fffccb5de8937b4d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6a8187f5c6f2e115d1a1c21ca2ec81a0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7041d544b28bff5f26dde49d77a2e87d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/747d1d7298f227da4193f23f3932ac8e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/749bd767d6654c80265f5ca0959dc8e1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/75870e6b6fe8335a7912ca4ea859a76a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/759bbbe7d51d98664d8072e51b24744b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7a1f4a9bcb1d7d1e515330c4f5c391ad +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7ad564910e515e335bb008989a97efb7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7b55037b89f2debe558b43fe7542e409 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7ff7dd624cb7a6db5ec99af129138020 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/80870efa2a2ddb1de325c224daff5712 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/856b05d9307e97e681bc5c7f3649f714 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8766064af197b444eb1f06a6650ca9c3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/894aeaae9cc8483fa9f7a5146ff6ff6f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8a559f967fac90d4ae5a84af92c111e1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8c5ee15b5860dcf2941abd00daf001eb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8c9393d7c6a1a2b6bb1fc9a9ccaba111 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8d476275ed52a5aa897cb7eef648dbc4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/906da6ff8c06db3e472a0a10985b668c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/94826bb92d888d50a265392a81ce1286 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/956d7ea9ee52ec12759995ab47f1e780 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/974812817397ff6032b286a281d9a163 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9ba0cab624f25b68f79447e62fbc6112 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a1c0fa5689dff4e7edcc4f175f9d54bf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a43280845b1d41babd3f6714cd2d1337 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a50e247ceb9e9af32260a73eadbb65cb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a668bf13b4df6854c8c1085b26daa63a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a78a33e8cea959257da93b3e67786300 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aa4822def20c419f0e50e2a38e73a1df +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aa94554c7d6f15d3f88e9710b043c2cc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/abde9800d767ab39abc91703e5a83d70 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b25e1f0b850e73d0e1ef154249ce8135 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b4e0977feb24777fe3df7dd188b2b123 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b4e12b8782fac2f3caaa4aea2f89087c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b8c47badf85ceedb2268ef3b0f074257 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bafd6678f36ffd5fb29e4d9055df1f97 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bc4b7beed5a786619d6c3855909cb077 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bfc0fef30976427a03ddccb1ce78d6e7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c104157fd9dbe5edc61a1889af968e19 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c37e2e0969ee5b3590335141a08ed884 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c3dc3ada4560805584739bfe7c2b24d9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c4d36397803a4adf8ea86a8936b2d5f5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c8f8b0ae15c86cf8aae9e3601758435e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cbbe8f22213647e8549911f486aee9b3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cc04ce51d1e3d02a64f2781ea0876af3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cebb517859b2ed48276bf54e0ba6dcec +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d311318a280b46ab076da5c419b210ab +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d48c8e1ff1b6fcdbacf6ab08f8bde111 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d7c40ebee2fb9471bab352337570ba40 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d9390b9983c2dcadf2533a63d0f7a84c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/da055188ac218679c8fe62932c379340 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/da4488b32bd6fb75c655a077956c9034 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e0f1660d21c6375d8a36eac87ae8ccbc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e1639f86099d91eb2fede327d443906f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e25f607f69c16bc5ffb481f9606b457e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e2c4f946939f2d7d0b42d86383755cae +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e4a2ab1f3bf2d0726dff720ae88e8abc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e4f46080338c0c52e3933999a7f8106d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e59a3c2ff941e0fdc7987168580bf4cc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e5ab921ab9e413144898d780049a5c88 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e6cfe2e09e34ec2b24494a74eed5243a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e994cc6f07f643c4c230a9b740fd03f5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ec87c33887ff6c0258bd8469a77bdcb4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/eccb73ad1563f9b070c4ffdf07ffff38 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ee5a41236d43159aac87f9224a0bcfb8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f00fb03eca205b5e302d9ae7ed652817 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f24a0e7771eab5bd17ee05c73c56649e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f2de4855fd4840abb2f6e80afee5f4ed +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f475ab32c44efa173bf8ba75435d2570 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f5165c4d7cee0e7cb99bc069fd4c09b9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f53b02f1d2cbab753c7931e700469bed +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f5cf5c65e6bf2039363f3b1e09bcdc9c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f975cba8c490022ddfc45bab0b512879 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fba4eeb0b33c40737a907a18ee0770a4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fbe8d6803f3e5a9ccb6eb7a285b95ee0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fd7e46e0b42a510b40f17d1f1bacf80e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fd9e24b6acf76f9d44cc8e26d3148e39 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fe03e8232ec516da863efecd7bb2678b +0 -0
- data/spec/requests/shared_spec.rb +0 -36
data/README.md
CHANGED
@@ -2,11 +2,23 @@
|
|
2
2
|
|
3
3
|
Open source mini content management system for programmers.
|
4
4
|
|
5
|
+
## Setup
|
6
|
+
|
7
|
+
For rails 4.x.x:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "sunrise-cms", :require => "sunrise"
|
11
|
+
```
|
12
|
+
|
13
|
+
For rails 3.x.x:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "sunrise-cms", "~> 0.7.x" :require => "sunrise"
|
17
|
+
```
|
18
|
+
|
5
19
|
## Instructions
|
6
20
|
|
7
21
|
### ActiveRecord
|
8
|
-
|
9
|
-
List of gems for [active_record](https://gist.github.com/4529926#file-gemfile-active_record).
|
10
22
|
|
11
23
|
```bash
|
12
24
|
$> rails g devise:install
|
@@ -24,8 +36,6 @@ $> rails g public_activity:migration
|
|
24
36
|
|
25
37
|
### Mongoid
|
26
38
|
|
27
|
-
List of gems for [mongoid](https://gist.github.com/4529926#file-gemfile-mongoid).
|
28
|
-
|
29
39
|
```bash
|
30
40
|
$> rails g sunrise:install --orm=mongoid
|
31
41
|
```
|
@@ -42,7 +52,7 @@ class SunriseProduct < Sunrise::AbstractModel
|
|
42
52
|
|
43
53
|
after_sort :clear_cache
|
44
54
|
|
45
|
-
|
55
|
+
index :thumbs do
|
46
56
|
scope { Product.includes(:picture) }
|
47
57
|
preview lambda { |product| product.picture.try(:url, :thumb) }
|
48
58
|
|
@@ -51,7 +61,7 @@ class SunriseProduct < Sunrise::AbstractModel
|
|
51
61
|
field :total_stock
|
52
62
|
end
|
53
63
|
|
54
|
-
|
64
|
+
export do
|
55
65
|
scope { Product.includes(:picture).recently.with_state(:finished) }
|
56
66
|
|
57
67
|
field :id
|
@@ -71,7 +81,7 @@ class SunriseProduct < Sunrise::AbstractModel
|
|
71
81
|
field :is_visible
|
72
82
|
end
|
73
83
|
|
74
|
-
|
84
|
+
form do
|
75
85
|
field :title
|
76
86
|
field :price
|
77
87
|
field :total_stock
|
@@ -139,15 +149,6 @@ For more info look at jbuilder https://rubygems.org/gems/jbuilder.
|
|
139
149
|
|
140
150
|
### Strong parameters
|
141
151
|
|
142
|
-
Sunrise include gem [strong_parameters](https://github.com/rails/strong_parameters)
|
143
|
-
In all models your need include module ActiveModel::ForbiddenAttributesProtection:
|
144
|
-
|
145
|
-
``` ruby
|
146
|
-
class Post < ActiveRecord::Base
|
147
|
-
include ActiveModel::ForbiddenAttributesProtection
|
148
|
-
end
|
149
|
-
```
|
150
|
-
|
151
152
|
Now in sunrise file you can perform attributes check.
|
152
153
|
By default permited_attributes allow edit all attributes.
|
153
154
|
|
@@ -192,4 +193,4 @@ config.to_prepare do
|
|
192
193
|
end
|
193
194
|
```
|
194
195
|
|
195
|
-
Copyright (c)
|
196
|
+
Copyright (c) 2014 Fodojo, released under the MIT license
|
@@ -55,18 +55,15 @@ module Sunrise
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def export
|
58
|
-
abstract_model.
|
59
|
-
@records = abstract_model.apply_scopes(params)
|
60
|
-
options = { :filename => abstract_model.export_filename,
|
61
|
-
:columns => abstract_model.export_columns }
|
58
|
+
@records = abstract_model.apply_scopes(params, false)
|
62
59
|
|
63
60
|
respond_to do |format|
|
64
61
|
format.xml { render :xml => @records }
|
65
62
|
format.json { render :json => @records }
|
66
|
-
format.csv { render
|
63
|
+
format.csv { render abstract_model.export_options.merge(:csv => @records) }
|
67
64
|
|
68
65
|
if defined?(Mime::XLSX)
|
69
|
-
format.xlsx { render
|
66
|
+
format.xlsx { render abstract_model.export_options.merge(:xlsx => @records) }
|
70
67
|
end
|
71
68
|
end
|
72
69
|
end
|
@@ -155,7 +152,7 @@ module Sunrise
|
|
155
152
|
end
|
156
153
|
|
157
154
|
def redirect_after_update(record = nil)
|
158
|
-
if abstract_model.
|
155
|
+
if abstract_model.without_index?
|
159
156
|
index_path(:model_name => abstract_model.plural)
|
160
157
|
else
|
161
158
|
scoped_index_path
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<div class="wysiwyg-holder">
|
8
8
|
<%= render :partial => "sunrise/shared/available_locales", :locals => {:form => f} if abstract_model.translate? %>
|
9
9
|
|
10
|
-
<%= render :partial => 'field', :collection => abstract_model.
|
10
|
+
<%= render :partial => 'field', :collection => abstract_model.form_fields, :locals => {:form => f} %>
|
11
11
|
</div>
|
12
12
|
|
13
13
|
<% if abstract_model.sidebar_groups? -%>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<%= link_to t('manage.filter'), scoped_index_path, :class => "filter-but ddmenu", :rel => "filter" %>
|
16
16
|
<% end %>
|
17
17
|
|
18
|
-
<% unless abstract_model.
|
18
|
+
<% unless abstract_model.without_index? %>
|
19
19
|
<div class="tabs-holder">
|
20
20
|
<%= content_tag :div, :class => 'tabs-item' do %>
|
21
21
|
<% if abstract_model.current_list == :table %>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<% else %>
|
24
24
|
<%= link_to image_tag('sunrise/empty.gif'), {:view=>"table"}, :class => "table", :title => t('manage.buttons.table') %>
|
25
25
|
<% end %>
|
26
|
-
<% end if abstract_model.config.
|
26
|
+
<% end if abstract_model.config.available_index_views.include?(:table) -%>
|
27
27
|
|
28
28
|
<%= content_tag :div, :class => 'tabs-item' do %>
|
29
29
|
<% if abstract_model.current_list == :thumbs %>
|
@@ -31,7 +31,7 @@
|
|
31
31
|
<% else %>
|
32
32
|
<%= link_to image_tag('sunrise/empty.gif'), {:view=>"thumbs"}, :class => "list", :title => t('manage.buttons.thumbs') %>
|
33
33
|
<% end %>
|
34
|
-
<% end if abstract_model.config.
|
34
|
+
<% end if abstract_model.config.available_index_views.include?(:thumbs) -%>
|
35
35
|
</div>
|
36
36
|
|
37
37
|
<% if abstract_model.sort_available? %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="rel-holder">
|
3
3
|
<div class="menu-holder">
|
4
4
|
<ul class="main-menu">
|
5
|
-
<% Sunrise::Config.
|
5
|
+
<% Sunrise::Config.navigation.each do |key, value| %>
|
6
6
|
<li>
|
7
7
|
<%= link_to "##{key}", :class => "ddmenu", :rel => key do -%>
|
8
8
|
<%= content_tag(:span, :class => key) do -%>
|
@@ -25,7 +25,7 @@
|
|
25
25
|
</ul>
|
26
26
|
</div>
|
27
27
|
|
28
|
-
<% Sunrise::Config.
|
28
|
+
<% Sunrise::Config.navigation.each do |key, value| -%>
|
29
29
|
<%= content_tag(:div, :id => "#{key}-container", :class => ["sub-wrapper", key], :style => "display: none;") do -%>
|
30
30
|
<div class="sub-inner">
|
31
31
|
<%= content_tag(:ul, :class => ["#{key}-list", "default-list"]) do -%>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class="act-buttons-wrapper">
|
3
3
|
<div class="but-holder"><div class="check"><input type="checkbox" /></div></div>
|
4
4
|
|
5
|
-
<% unless abstract_model.
|
5
|
+
<% unless abstract_model.without_index? %>
|
6
6
|
<% abstract_model.list.buttons.each do |name| %>
|
7
7
|
<% if can? name, abstract_model.model, :context => :sunrise %>
|
8
8
|
<%= render :partial => "sunrise/manager/buttons/#{name}", :locals => {:model => abstract_model} %>
|
data/config/routes.rb
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
Sunrise::Engine.routes.draw do
|
2
|
-
root :
|
2
|
+
root to: Sunrise::Config.root_controller
|
3
3
|
|
4
|
-
get "/
|
5
|
-
get "/dashboard/p/:page", :to => "dashboard#index", :page => /\d+/
|
4
|
+
get "/dashboard/p/:page", to: "dashboard#index", page: /\d+/
|
6
5
|
|
7
|
-
resource :settings, :
|
6
|
+
resource :settings, only: [:edit, :update]
|
8
7
|
|
9
8
|
controller "manager" do
|
10
9
|
scope ":model_name" do
|
11
|
-
get "/", :
|
12
|
-
get "/export.:format", :
|
13
|
-
post "/sort", :
|
14
|
-
get "/new", :
|
15
|
-
post "/new", :
|
16
|
-
delete "/mass_destroy", :
|
10
|
+
get "/", to: :index, as: :index
|
11
|
+
get "/export.:format", to: :export, as: :export
|
12
|
+
post "/sort", to: :sort, as: :sort
|
13
|
+
get "/new", to: :new, as: :new
|
14
|
+
post "/new", to: :create, as: :create
|
15
|
+
delete "/mass_destroy", to: :mass_destroy, as: :mass_destroy
|
17
16
|
|
18
17
|
scope ":id" do
|
19
|
-
get "/", :
|
20
|
-
get "/edit", :
|
21
|
-
patch "/edit", :
|
22
|
-
get "/delete", :
|
23
|
-
delete "/delete", :
|
18
|
+
get "/", to: :show, as: :show
|
19
|
+
get "/edit", to: :edit, as: :edit
|
20
|
+
patch "/edit", to: :update, as: :update
|
21
|
+
get "/delete", to: :delete, as: :delete
|
22
|
+
delete "/delete", to: :destroy, as: :destroy
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -15,13 +15,13 @@ Sunrise.setup do |config|
|
|
15
15
|
# The display for a model instance (i.e. a single database record).
|
16
16
|
# config.label_methods = [:title, :name]
|
17
17
|
|
18
|
-
#
|
19
|
-
# config.
|
18
|
+
# Default list template view (default: "thumbs")
|
19
|
+
# config.default_index_view = "thumbs"
|
20
20
|
|
21
21
|
# Avariable lists views (default: [:list, :thumbs, :table])
|
22
|
-
# config.
|
22
|
+
# config.available_index_views = [:list, :thumbs, :table]
|
23
23
|
|
24
|
-
#
|
24
|
+
# Default sort order column (default: "sort_order")
|
25
25
|
# config.sort_column = "sort_order"
|
26
26
|
|
27
27
|
# Find template before rendering (default: true)
|
@@ -39,13 +39,16 @@ Sunrise.setup do |config|
|
|
39
39
|
|
40
40
|
# Lists the formats that should be treated as navigational (default: [:html, :json])
|
41
41
|
# config.navigational_formats = [:html, :json]
|
42
|
+
|
43
|
+
# Welcome (root) controller path
|
44
|
+
# config.root_controller = "dashboard#index"
|
42
45
|
end
|
43
46
|
|
44
47
|
PublicActivity::Config.set do
|
45
48
|
orm :active_record
|
46
49
|
end
|
47
50
|
|
48
|
-
#if Settings.table_exists?
|
49
|
-
# Settings.
|
50
|
-
# Settings.
|
51
|
-
#end
|
51
|
+
# if Settings.table_exists?
|
52
|
+
# Settings.some_setting = "value"
|
53
|
+
# Settings.some_setting2 = "value2"
|
54
|
+
# end
|
@@ -15,13 +15,13 @@ Sunrise.setup do |config|
|
|
15
15
|
# The display for a model instance (i.e. a single database record).
|
16
16
|
# config.label_methods = [:title, :name]
|
17
17
|
|
18
|
-
#
|
19
|
-
# config.
|
18
|
+
# Default list template view (default: "thumbs")
|
19
|
+
# config.default_index_view = "thumbs"
|
20
20
|
|
21
21
|
# Avariable lists views (default: [:list, :thumbs, :table])
|
22
|
-
# config.
|
22
|
+
# config.available_index_views = [:list, :thumbs, :table]
|
23
23
|
|
24
|
-
#
|
24
|
+
# Default sort order column (default: "sort_order")
|
25
25
|
# config.sort_column = "sort_order"
|
26
26
|
|
27
27
|
# Find template before rendering (default: true)
|
@@ -39,6 +39,9 @@ Sunrise.setup do |config|
|
|
39
39
|
|
40
40
|
# Lists the formats that should be treated as navigational (default: [:html, :json])
|
41
41
|
# config.navigational_formats = [:html, :json]
|
42
|
+
|
43
|
+
# Welcome (root) controller path
|
44
|
+
# config.root_controller = "dashboard#index"
|
42
45
|
end
|
43
46
|
|
44
47
|
PublicActivity::Config.set do
|
@@ -46,6 +49,6 @@ PublicActivity::Config.set do
|
|
46
49
|
end
|
47
50
|
|
48
51
|
#if Settings.table_exists?
|
49
|
-
# Settings.
|
50
|
-
# Settings.
|
52
|
+
# Settings.some_setting = "value"
|
53
|
+
# Settings.some_setting2 = "value2"
|
51
54
|
#end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
class SunriseNavigation < Sunrise::Config::Navigation
|
2
|
-
navigation :main do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
m.item :settings, edit_settings_path, :class => "icon4"
|
2
|
+
navigation :main do
|
3
|
+
item :dashboard, root_path, class: "icon1"
|
4
|
+
item :structures, index_path(model_name: "structures"), class: "icon2"
|
5
|
+
item :users, index_path(model_name: "users"), class: "icon3"
|
6
|
+
item :settings, edit_settings_path, class: "icon4"
|
8
7
|
end
|
9
8
|
|
10
|
-
navigation :creates do
|
11
|
-
|
12
|
-
|
9
|
+
navigation :creates do
|
10
|
+
item :structures, new_path(model_name: "structures")
|
11
|
+
item :users, new_path(model_name: "users")
|
13
12
|
end
|
14
13
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class SunrisePage < Sunrise::AbstractModel
|
2
2
|
self.resource_name = "Structure"
|
3
3
|
|
4
|
-
|
4
|
+
index false
|
5
5
|
|
6
|
-
|
7
|
-
field :
|
8
|
-
field :sidebar, :
|
6
|
+
form do
|
7
|
+
field :content, as: :text
|
8
|
+
field :sidebar, as: :text
|
9
9
|
end
|
10
10
|
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
class SunriseStructure < Sunrise::AbstractModel
|
3
3
|
self.resource_name = "Structure"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
default_index_view :tree
|
6
|
+
available_index_views [:tree, :thumbs]
|
7
7
|
|
8
|
-
|
8
|
+
index :tree do
|
9
9
|
field :title
|
10
10
|
field :updated_at
|
11
11
|
field :id
|
@@ -17,16 +17,16 @@ class SunriseStructure < Sunrise::AbstractModel
|
|
17
17
|
field :is_visible
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
form do
|
21
21
|
field :title
|
22
22
|
field :redirect_url
|
23
23
|
field :slug
|
24
|
-
field :parent_id, :
|
25
|
-
field :structure_type_id, :
|
26
|
-
field :position_type_id, :
|
24
|
+
field :parent_id, collection: lambda { Structure.nested_set_options() {|i| "#{'–' * i.depth} #{i.title}"} }, if: lambda { |s| s.moveable? }
|
25
|
+
field :structure_type_id, collection: lambda { StructureType.all }, include_blank: false
|
26
|
+
field :position_type_id, collection: lambda { PositionType.all }, include_blank: false
|
27
27
|
field :is_visible
|
28
28
|
|
29
|
-
group :meta_tags, :
|
29
|
+
group :meta_tags, holder: :sidebar do
|
30
30
|
field :tag_title
|
31
31
|
field :tag_keywords
|
32
32
|
field :tag_description
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class SunriseUser < Sunrise::AbstractModel
|
2
2
|
self.resource_name = "User"
|
3
3
|
|
4
|
-
|
4
|
+
index :table do
|
5
5
|
field :email
|
6
6
|
field :updated_at
|
7
7
|
field :id
|
@@ -12,12 +12,12 @@ class SunriseUser < Sunrise::AbstractModel
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
index :thumbs do
|
16
16
|
scope { User.includes(:avatar) }
|
17
17
|
preview lambda { |user| user.avatar.try(:url, :thumb) }
|
18
18
|
|
19
|
-
field :email, :
|
20
|
-
field :updated_at, :
|
19
|
+
field :email, label: false
|
20
|
+
field :updated_at, label: false
|
21
21
|
field :id
|
22
22
|
|
23
23
|
group :search do
|
@@ -25,8 +25,14 @@ class SunriseUser < Sunrise::AbstractModel
|
|
25
25
|
field :name
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
export do
|
30
|
+
field :id
|
31
|
+
field :name
|
32
|
+
field :email
|
33
|
+
end
|
28
34
|
|
29
|
-
|
35
|
+
form do
|
30
36
|
permited_attributes lambda { |user|
|
31
37
|
user.admin? ? :all : [:name, :password, :password_confirmation, :avatar_attributes]
|
32
38
|
}
|
@@ -35,16 +41,10 @@ class SunriseUser < Sunrise::AbstractModel
|
|
35
41
|
field :email
|
36
42
|
field :password
|
37
43
|
field :password_confirmation
|
38
|
-
field :role_type_id, :
|
44
|
+
field :role_type_id, collection: lambda { RoleType.all }
|
39
45
|
|
40
|
-
group :bottom, :
|
41
|
-
field :avatar, :
|
46
|
+
group :bottom, holder: :bottom do
|
47
|
+
field :avatar, as: :uploader
|
42
48
|
end
|
43
49
|
end
|
44
|
-
|
45
|
-
list :export do
|
46
|
-
field :id
|
47
|
-
field :name
|
48
|
-
field :email
|
49
|
-
end
|
50
50
|
end
|
@@ -55,8 +55,8 @@ module Sunrise
|
|
55
55
|
|
56
56
|
def initialize(params = {})
|
57
57
|
@model_name = model.model_name
|
58
|
-
@current_list = config.
|
59
|
-
@
|
58
|
+
@current_list = config.default_index_view
|
59
|
+
@available_index_views = config.available_index_views
|
60
60
|
@sort_column = config.sort_column
|
61
61
|
@request_params = params.symbolize_keys
|
62
62
|
self.current_list = params[:view]
|
@@ -68,16 +68,11 @@ module Sunrise
|
|
68
68
|
|
69
69
|
# Save current list view
|
70
70
|
def current_list=(value)
|
71
|
-
|
72
|
-
@current_list = value.
|
71
|
+
if value && @available_index_views.include?(value.to_sym)
|
72
|
+
@current_list = value.to_sym
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
# Key which stored list settings
|
77
|
-
def list_key
|
78
|
-
["list", current_list].compact.join('_').to_sym
|
79
|
-
end
|
80
|
-
|
81
76
|
# Load association record
|
82
77
|
def parent_record
|
83
78
|
@parent_record ||= find_parent_record
|
@@ -91,13 +86,13 @@ module Sunrise
|
|
91
86
|
|
92
87
|
# Get current list settings
|
93
88
|
def list
|
94
|
-
return false if
|
95
|
-
config.
|
89
|
+
return false if without_index?
|
90
|
+
config.index(current_list)
|
96
91
|
end
|
97
92
|
|
98
|
-
# Is
|
99
|
-
def
|
100
|
-
config.
|
93
|
+
# Is index config disabled
|
94
|
+
def without_index?
|
95
|
+
config.index === false
|
101
96
|
end
|
102
97
|
|
103
98
|
def search_available?
|
@@ -167,15 +162,15 @@ module Sunrise
|
|
167
162
|
end
|
168
163
|
|
169
164
|
# Convert request params to model scopes
|
170
|
-
def apply_scopes(params = nil)
|
171
|
-
raise ::AbstractController::ActionNotFound.new("List config is turn off") if
|
165
|
+
def apply_scopes(params = nil, pagination = true)
|
166
|
+
raise ::AbstractController::ActionNotFound.new("List config is turn off") if without_index?
|
172
167
|
params ||= @request_params
|
173
168
|
|
174
169
|
scope = default_scope(params)
|
175
170
|
|
176
171
|
if current_list == :tree
|
177
172
|
scope = scope.roots
|
178
|
-
|
173
|
+
elsif pagination
|
179
174
|
scope = page_scope(scope, params[:page], params[:per])
|
180
175
|
end
|
181
176
|
|
@@ -187,7 +182,7 @@ module Sunrise
|
|
187
182
|
params ||= @request_params
|
188
183
|
|
189
184
|
scope = model.sunrise_search(params[:search]) if model.respond_to?(:sunrise_search) && !params[:search].blank?
|
190
|
-
scope ||= model.
|
185
|
+
scope ||= model.where(nil)
|
191
186
|
|
192
187
|
scope = scope.merge(association_scope) unless parent_record.nil?
|
193
188
|
scope = scope.merge(sort_scope(params[:sort])) unless params[:sort].blank?
|
@@ -221,20 +216,27 @@ module Sunrise
|
|
221
216
|
|
222
217
|
# List of columns names to be exported
|
223
218
|
def export_columns
|
224
|
-
|
219
|
+
@export_columns ||= (config.export ? config.export.fields.map(&:name) : model.column_names)
|
225
220
|
end
|
226
221
|
|
227
222
|
# Filename for export data
|
228
223
|
def export_filename
|
229
224
|
@export_filename ||= [plural, Time.now.strftime("%Y-%m-%d_%Hh%Mm%S")].join('_')
|
230
225
|
end
|
226
|
+
|
227
|
+
def export_options
|
228
|
+
{
|
229
|
+
:filename => export_filename,
|
230
|
+
:columns => export_columns
|
231
|
+
}
|
232
|
+
end
|
231
233
|
|
232
|
-
def
|
233
|
-
config.
|
234
|
+
def form_fields
|
235
|
+
config.form.fields || []
|
234
236
|
end
|
235
237
|
|
236
238
|
def permit_attributes(params, user = nil)
|
237
|
-
value = config.
|
239
|
+
value = config.form.permited_attributes
|
238
240
|
|
239
241
|
attrs = case value
|
240
242
|
when Proc then value.call(user)
|
@@ -252,17 +254,17 @@ module Sunrise
|
|
252
254
|
|
253
255
|
# Has translated columns
|
254
256
|
def translate?
|
255
|
-
!config.
|
257
|
+
!config.form.groups[:translate].blank?
|
256
258
|
end
|
257
259
|
|
258
260
|
# Files to translate
|
259
261
|
def translate_fields
|
260
|
-
config.
|
262
|
+
config.form.groups[:translate].try(:fields) || []
|
261
263
|
end
|
262
264
|
|
263
265
|
# Find sidebar groups
|
264
266
|
def sidebar_groups
|
265
|
-
@sidebar_groups ||= config.
|
267
|
+
@sidebar_groups ||= config.form.groups.values.select { |v| v.sidebar? }
|
266
268
|
end
|
267
269
|
|
268
270
|
# Check if sidebar groups exists
|
@@ -272,7 +274,7 @@ module Sunrise
|
|
272
274
|
|
273
275
|
# Find bottom groups
|
274
276
|
def bottom_groups
|
275
|
-
@bottom_groups ||= config.
|
277
|
+
@bottom_groups ||= config.form.groups.values.select { |v| v.bottom? }
|
276
278
|
end
|
277
279
|
|
278
280
|
protected
|
@@ -299,4 +301,4 @@ module Sunrise
|
|
299
301
|
!(@request_params[:parent_id].blank? || @request_params[:parent_type].blank?)
|
300
302
|
end
|
301
303
|
end
|
302
|
-
end
|
304
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'sunrise/config/base'
|
2
|
+
require 'sunrise/config/has_groups'
|
3
|
+
require 'sunrise/config/has_fields'
|
4
|
+
|
5
|
+
module Sunrise
|
6
|
+
module Config
|
7
|
+
class Export < Base
|
8
|
+
include Sunrise::Config::HasFields
|
9
|
+
|
10
|
+
# Column to sort
|
11
|
+
register_instance_option :sort_column do
|
12
|
+
abstract_model.model.primary_key
|
13
|
+
end
|
14
|
+
|
15
|
+
# Sort direction
|
16
|
+
register_instance_option :sort_mode do
|
17
|
+
Sunrise::Config.default_sort_mode
|
18
|
+
end
|
19
|
+
|
20
|
+
# Default scope
|
21
|
+
register_instance_option(:scope) do
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|