dm_core 4.2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (522) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README.md +25 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/images/dm_core/draft_menu_bg.png +0 -0
  6. data/app/assets/images/dm_core/expand.png +0 -0
  7. data/app/assets/images/dm_core/flags/ad.gif +0 -0
  8. data/app/assets/images/dm_core/flags/ae.gif +0 -0
  9. data/app/assets/images/dm_core/flags/af.gif +0 -0
  10. data/app/assets/images/dm_core/flags/ag.gif +0 -0
  11. data/app/assets/images/dm_core/flags/ai.gif +0 -0
  12. data/app/assets/images/dm_core/flags/al.gif +0 -0
  13. data/app/assets/images/dm_core/flags/am.gif +0 -0
  14. data/app/assets/images/dm_core/flags/an.gif +0 -0
  15. data/app/assets/images/dm_core/flags/ao.gif +0 -0
  16. data/app/assets/images/dm_core/flags/ar.gif +0 -0
  17. data/app/assets/images/dm_core/flags/as.gif +0 -0
  18. data/app/assets/images/dm_core/flags/at.gif +0 -0
  19. data/app/assets/images/dm_core/flags/au.gif +0 -0
  20. data/app/assets/images/dm_core/flags/aw.gif +0 -0
  21. data/app/assets/images/dm_core/flags/ax.gif +0 -0
  22. data/app/assets/images/dm_core/flags/az.gif +0 -0
  23. data/app/assets/images/dm_core/flags/ba.gif +0 -0
  24. data/app/assets/images/dm_core/flags/bb.gif +0 -0
  25. data/app/assets/images/dm_core/flags/bd.gif +0 -0
  26. data/app/assets/images/dm_core/flags/be.gif +0 -0
  27. data/app/assets/images/dm_core/flags/bf.gif +0 -0
  28. data/app/assets/images/dm_core/flags/bg.gif +0 -0
  29. data/app/assets/images/dm_core/flags/bh.gif +0 -0
  30. data/app/assets/images/dm_core/flags/bi.gif +0 -0
  31. data/app/assets/images/dm_core/flags/bj.gif +0 -0
  32. data/app/assets/images/dm_core/flags/bm.gif +0 -0
  33. data/app/assets/images/dm_core/flags/bn.gif +0 -0
  34. data/app/assets/images/dm_core/flags/bo.gif +0 -0
  35. data/app/assets/images/dm_core/flags/br.gif +0 -0
  36. data/app/assets/images/dm_core/flags/bs.gif +0 -0
  37. data/app/assets/images/dm_core/flags/bt.gif +0 -0
  38. data/app/assets/images/dm_core/flags/bv.gif +0 -0
  39. data/app/assets/images/dm_core/flags/bw.gif +0 -0
  40. data/app/assets/images/dm_core/flags/by.gif +0 -0
  41. data/app/assets/images/dm_core/flags/bz.gif +0 -0
  42. data/app/assets/images/dm_core/flags/ca.gif +0 -0
  43. data/app/assets/images/dm_core/flags/cc.gif +0 -0
  44. data/app/assets/images/dm_core/flags/cd.gif +0 -0
  45. data/app/assets/images/dm_core/flags/cf.gif +0 -0
  46. data/app/assets/images/dm_core/flags/cg.gif +0 -0
  47. data/app/assets/images/dm_core/flags/ch.gif +0 -0
  48. data/app/assets/images/dm_core/flags/ci.gif +0 -0
  49. data/app/assets/images/dm_core/flags/ck.gif +0 -0
  50. data/app/assets/images/dm_core/flags/cl.gif +0 -0
  51. data/app/assets/images/dm_core/flags/cm.gif +0 -0
  52. data/app/assets/images/dm_core/flags/cn.gif +0 -0
  53. data/app/assets/images/dm_core/flags/co.gif +0 -0
  54. data/app/assets/images/dm_core/flags/cr.gif +0 -0
  55. data/app/assets/images/dm_core/flags/cs.gif +0 -0
  56. data/app/assets/images/dm_core/flags/cu.gif +0 -0
  57. data/app/assets/images/dm_core/flags/cv.gif +0 -0
  58. data/app/assets/images/dm_core/flags/cx.gif +0 -0
  59. data/app/assets/images/dm_core/flags/cy.gif +0 -0
  60. data/app/assets/images/dm_core/flags/cz.gif +0 -0
  61. data/app/assets/images/dm_core/flags/de.gif +0 -0
  62. data/app/assets/images/dm_core/flags/dj.gif +0 -0
  63. data/app/assets/images/dm_core/flags/dk.gif +0 -0
  64. data/app/assets/images/dm_core/flags/dm.gif +0 -0
  65. data/app/assets/images/dm_core/flags/do.gif +0 -0
  66. data/app/assets/images/dm_core/flags/dz.gif +0 -0
  67. data/app/assets/images/dm_core/flags/ec.gif +0 -0
  68. data/app/assets/images/dm_core/flags/ee.gif +0 -0
  69. data/app/assets/images/dm_core/flags/eg.gif +0 -0
  70. data/app/assets/images/dm_core/flags/eh.gif +0 -0
  71. data/app/assets/images/dm_core/flags/en.gif +0 -0
  72. data/app/assets/images/dm_core/flags/england.gif +0 -0
  73. data/app/assets/images/dm_core/flags/er.gif +0 -0
  74. data/app/assets/images/dm_core/flags/es.gif +0 -0
  75. data/app/assets/images/dm_core/flags/et.gif +0 -0
  76. data/app/assets/images/dm_core/flags/fam.gif +0 -0
  77. data/app/assets/images/dm_core/flags/fi.gif +0 -0
  78. data/app/assets/images/dm_core/flags/fj.gif +0 -0
  79. data/app/assets/images/dm_core/flags/fk.gif +0 -0
  80. data/app/assets/images/dm_core/flags/fm.gif +0 -0
  81. data/app/assets/images/dm_core/flags/fo.gif +0 -0
  82. data/app/assets/images/dm_core/flags/fr.gif +0 -0
  83. data/app/assets/images/dm_core/flags/ga.gif +0 -0
  84. data/app/assets/images/dm_core/flags/gb.gif +0 -0
  85. data/app/assets/images/dm_core/flags/gd.gif +0 -0
  86. data/app/assets/images/dm_core/flags/ge.gif +0 -0
  87. data/app/assets/images/dm_core/flags/gh.gif +0 -0
  88. data/app/assets/images/dm_core/flags/gi.gif +0 -0
  89. data/app/assets/images/dm_core/flags/gl.gif +0 -0
  90. data/app/assets/images/dm_core/flags/gm.gif +0 -0
  91. data/app/assets/images/dm_core/flags/gn.gif +0 -0
  92. data/app/assets/images/dm_core/flags/gp.gif +0 -0
  93. data/app/assets/images/dm_core/flags/gq.gif +0 -0
  94. data/app/assets/images/dm_core/flags/gr.gif +0 -0
  95. data/app/assets/images/dm_core/flags/gs.gif +0 -0
  96. data/app/assets/images/dm_core/flags/gt.gif +0 -0
  97. data/app/assets/images/dm_core/flags/gu.gif +0 -0
  98. data/app/assets/images/dm_core/flags/gw.gif +0 -0
  99. data/app/assets/images/dm_core/flags/gy.gif +0 -0
  100. data/app/assets/images/dm_core/flags/hk.gif +0 -0
  101. data/app/assets/images/dm_core/flags/hn.gif +0 -0
  102. data/app/assets/images/dm_core/flags/hr.gif +0 -0
  103. data/app/assets/images/dm_core/flags/ht.gif +0 -0
  104. data/app/assets/images/dm_core/flags/hu.gif +0 -0
  105. data/app/assets/images/dm_core/flags/id.gif +0 -0
  106. data/app/assets/images/dm_core/flags/ie.gif +0 -0
  107. data/app/assets/images/dm_core/flags/il.gif +0 -0
  108. data/app/assets/images/dm_core/flags/in.gif +0 -0
  109. data/app/assets/images/dm_core/flags/io.gif +0 -0
  110. data/app/assets/images/dm_core/flags/iq.gif +0 -0
  111. data/app/assets/images/dm_core/flags/ir.gif +0 -0
  112. data/app/assets/images/dm_core/flags/is.gif +0 -0
  113. data/app/assets/images/dm_core/flags/it.gif +0 -0
  114. data/app/assets/images/dm_core/flags/ja.gif +0 -0
  115. data/app/assets/images/dm_core/flags/jm.gif +0 -0
  116. data/app/assets/images/dm_core/flags/jo.gif +0 -0
  117. data/app/assets/images/dm_core/flags/ke.gif +0 -0
  118. data/app/assets/images/dm_core/flags/kg.gif +0 -0
  119. data/app/assets/images/dm_core/flags/kh.gif +0 -0
  120. data/app/assets/images/dm_core/flags/ki.gif +0 -0
  121. data/app/assets/images/dm_core/flags/km.gif +0 -0
  122. data/app/assets/images/dm_core/flags/kn.gif +0 -0
  123. data/app/assets/images/dm_core/flags/kp.gif +0 -0
  124. data/app/assets/images/dm_core/flags/kr.gif +0 -0
  125. data/app/assets/images/dm_core/flags/kw.gif +0 -0
  126. data/app/assets/images/dm_core/flags/ky.gif +0 -0
  127. data/app/assets/images/dm_core/flags/kz.gif +0 -0
  128. data/app/assets/images/dm_core/flags/la.gif +0 -0
  129. data/app/assets/images/dm_core/flags/lb.gif +0 -0
  130. data/app/assets/images/dm_core/flags/lc.gif +0 -0
  131. data/app/assets/images/dm_core/flags/li.gif +0 -0
  132. data/app/assets/images/dm_core/flags/lk.gif +0 -0
  133. data/app/assets/images/dm_core/flags/lr.gif +0 -0
  134. data/app/assets/images/dm_core/flags/ls.gif +0 -0
  135. data/app/assets/images/dm_core/flags/lt.gif +0 -0
  136. data/app/assets/images/dm_core/flags/lu.gif +0 -0
  137. data/app/assets/images/dm_core/flags/lv.gif +0 -0
  138. data/app/assets/images/dm_core/flags/ly.gif +0 -0
  139. data/app/assets/images/dm_core/flags/ma.gif +0 -0
  140. data/app/assets/images/dm_core/flags/mc.gif +0 -0
  141. data/app/assets/images/dm_core/flags/md.gif +0 -0
  142. data/app/assets/images/dm_core/flags/mg.gif +0 -0
  143. data/app/assets/images/dm_core/flags/mh.gif +0 -0
  144. data/app/assets/images/dm_core/flags/mk.gif +0 -0
  145. data/app/assets/images/dm_core/flags/ml.gif +0 -0
  146. data/app/assets/images/dm_core/flags/mm.gif +0 -0
  147. data/app/assets/images/dm_core/flags/mn.gif +0 -0
  148. data/app/assets/images/dm_core/flags/mo.gif +0 -0
  149. data/app/assets/images/dm_core/flags/mp.gif +0 -0
  150. data/app/assets/images/dm_core/flags/mq.gif +0 -0
  151. data/app/assets/images/dm_core/flags/mr.gif +0 -0
  152. data/app/assets/images/dm_core/flags/ms.gif +0 -0
  153. data/app/assets/images/dm_core/flags/mt.gif +0 -0
  154. data/app/assets/images/dm_core/flags/mu.gif +0 -0
  155. data/app/assets/images/dm_core/flags/mv.gif +0 -0
  156. data/app/assets/images/dm_core/flags/mw.gif +0 -0
  157. data/app/assets/images/dm_core/flags/mx.gif +0 -0
  158. data/app/assets/images/dm_core/flags/my.gif +0 -0
  159. data/app/assets/images/dm_core/flags/mz.gif +0 -0
  160. data/app/assets/images/dm_core/flags/na.gif +0 -0
  161. data/app/assets/images/dm_core/flags/nc.gif +0 -0
  162. data/app/assets/images/dm_core/flags/ne.gif +0 -0
  163. data/app/assets/images/dm_core/flags/nf.gif +0 -0
  164. data/app/assets/images/dm_core/flags/ng.gif +0 -0
  165. data/app/assets/images/dm_core/flags/ni.gif +0 -0
  166. data/app/assets/images/dm_core/flags/nl.gif +0 -0
  167. data/app/assets/images/dm_core/flags/no.gif +0 -0
  168. data/app/assets/images/dm_core/flags/np.gif +0 -0
  169. data/app/assets/images/dm_core/flags/nr.gif +0 -0
  170. data/app/assets/images/dm_core/flags/nu.gif +0 -0
  171. data/app/assets/images/dm_core/flags/nz.gif +0 -0
  172. data/app/assets/images/dm_core/flags/om.gif +0 -0
  173. data/app/assets/images/dm_core/flags/pa.gif +0 -0
  174. data/app/assets/images/dm_core/flags/pe.gif +0 -0
  175. data/app/assets/images/dm_core/flags/pf.gif +0 -0
  176. data/app/assets/images/dm_core/flags/pg.gif +0 -0
  177. data/app/assets/images/dm_core/flags/ph.gif +0 -0
  178. data/app/assets/images/dm_core/flags/pk.gif +0 -0
  179. data/app/assets/images/dm_core/flags/pl.gif +0 -0
  180. data/app/assets/images/dm_core/flags/pm.gif +0 -0
  181. data/app/assets/images/dm_core/flags/pn.gif +0 -0
  182. data/app/assets/images/dm_core/flags/pr.gif +0 -0
  183. data/app/assets/images/dm_core/flags/ps.gif +0 -0
  184. data/app/assets/images/dm_core/flags/pt.gif +0 -0
  185. data/app/assets/images/dm_core/flags/pw.gif +0 -0
  186. data/app/assets/images/dm_core/flags/py.gif +0 -0
  187. data/app/assets/images/dm_core/flags/qa.gif +0 -0
  188. data/app/assets/images/dm_core/flags/ro.gif +0 -0
  189. data/app/assets/images/dm_core/flags/ru.gif +0 -0
  190. data/app/assets/images/dm_core/flags/rw.gif +0 -0
  191. data/app/assets/images/dm_core/flags/sa.gif +0 -0
  192. data/app/assets/images/dm_core/flags/sb.gif +0 -0
  193. data/app/assets/images/dm_core/flags/sc.gif +0 -0
  194. data/app/assets/images/dm_core/flags/scotland.gif +0 -0
  195. data/app/assets/images/dm_core/flags/sd.gif +0 -0
  196. data/app/assets/images/dm_core/flags/se.gif +0 -0
  197. data/app/assets/images/dm_core/flags/sg.gif +0 -0
  198. data/app/assets/images/dm_core/flags/sh.gif +0 -0
  199. data/app/assets/images/dm_core/flags/si.gif +0 -0
  200. data/app/assets/images/dm_core/flags/sk.gif +0 -0
  201. data/app/assets/images/dm_core/flags/sl.gif +0 -0
  202. data/app/assets/images/dm_core/flags/sm.gif +0 -0
  203. data/app/assets/images/dm_core/flags/sn.gif +0 -0
  204. data/app/assets/images/dm_core/flags/so.gif +0 -0
  205. data/app/assets/images/dm_core/flags/sr.gif +0 -0
  206. data/app/assets/images/dm_core/flags/st.gif +0 -0
  207. data/app/assets/images/dm_core/flags/sv.gif +0 -0
  208. data/app/assets/images/dm_core/flags/sy.gif +0 -0
  209. data/app/assets/images/dm_core/flags/sz.gif +0 -0
  210. data/app/assets/images/dm_core/flags/tc.gif +0 -0
  211. data/app/assets/images/dm_core/flags/td.gif +0 -0
  212. data/app/assets/images/dm_core/flags/tf.gif +0 -0
  213. data/app/assets/images/dm_core/flags/tg.gif +0 -0
  214. data/app/assets/images/dm_core/flags/th.gif +0 -0
  215. data/app/assets/images/dm_core/flags/tj.gif +0 -0
  216. data/app/assets/images/dm_core/flags/tk.gif +0 -0
  217. data/app/assets/images/dm_core/flags/tl.gif +0 -0
  218. data/app/assets/images/dm_core/flags/tm.gif +0 -0
  219. data/app/assets/images/dm_core/flags/tn.gif +0 -0
  220. data/app/assets/images/dm_core/flags/to.gif +0 -0
  221. data/app/assets/images/dm_core/flags/tr.gif +0 -0
  222. data/app/assets/images/dm_core/flags/tt.gif +0 -0
  223. data/app/assets/images/dm_core/flags/tv.gif +0 -0
  224. data/app/assets/images/dm_core/flags/tw.gif +0 -0
  225. data/app/assets/images/dm_core/flags/tz.gif +0 -0
  226. data/app/assets/images/dm_core/flags/ua.gif +0 -0
  227. data/app/assets/images/dm_core/flags/ug.gif +0 -0
  228. data/app/assets/images/dm_core/flags/um.gif +0 -0
  229. data/app/assets/images/dm_core/flags/us.gif +0 -0
  230. data/app/assets/images/dm_core/flags/uy.gif +0 -0
  231. data/app/assets/images/dm_core/flags/uz.gif +0 -0
  232. data/app/assets/images/dm_core/flags/va.gif +0 -0
  233. data/app/assets/images/dm_core/flags/vc.gif +0 -0
  234. data/app/assets/images/dm_core/flags/ve.gif +0 -0
  235. data/app/assets/images/dm_core/flags/vg.gif +0 -0
  236. data/app/assets/images/dm_core/flags/vi.gif +0 -0
  237. data/app/assets/images/dm_core/flags/vn.gif +0 -0
  238. data/app/assets/images/dm_core/flags/vu.gif +0 -0
  239. data/app/assets/images/dm_core/flags/wales.gif +0 -0
  240. data/app/assets/images/dm_core/flags/wf.gif +0 -0
  241. data/app/assets/images/dm_core/flags/ws.gif +0 -0
  242. data/app/assets/images/dm_core/flags/ye.gif +0 -0
  243. data/app/assets/images/dm_core/flags/yt.gif +0 -0
  244. data/app/assets/images/dm_core/flags/za.gif +0 -0
  245. data/app/assets/images/dm_core/flags/zm.gif +0 -0
  246. data/app/assets/images/dm_core/flags/zw.gif +0 -0
  247. data/app/assets/images/dm_core/user.gif +0 -0
  248. data/app/assets/javascripts/dm_core/admin.js +223 -0
  249. data/app/assets/javascripts/dm_core/admin_extra.js.coffee +118 -0
  250. data/app/assets/javascripts/dm_core/application.js +14 -0
  251. data/app/assets/javascripts/dm_core/common_js.js.coffee +61 -0
  252. data/app/assets/javascripts/dm_core/underscore-1.4.4-min.js +1 -0
  253. data/app/assets/javascripts/dm_core/underscore-1.4.4.js +1227 -0
  254. data/app/assets/stylesheets/dm_core/admin.css +250 -0
  255. data/app/assets/stylesheets/dm_core/application.css +31 -0
  256. data/app/assets/stylesheets/dm_core/font-awesome.css +1479 -0
  257. data/app/assets/stylesheets/dm_core/font/FontAwesome.otf +0 -0
  258. data/app/assets/stylesheets/dm_core/font/fontawesome-webfont.eot +0 -0
  259. data/app/assets/stylesheets/dm_core/font/fontawesome-webfont.svg +399 -0
  260. data/app/assets/stylesheets/dm_core/font/fontawesome-webfont.ttf +0 -0
  261. data/app/assets/stylesheets/dm_core/font/fontawesome-webfont.woff +0 -0
  262. data/app/controllers/dm_core/admin/accounts_controller.rb +125 -0
  263. data/app/controllers/dm_core/admin/admin_controller.rb +133 -0
  264. data/app/controllers/dm_core/admin/comments_controller.rb +70 -0
  265. data/app/controllers/dm_core/admin/dashboard_controller.rb +38 -0
  266. data/app/controllers/dm_core/admin/system_controller.rb +44 -0
  267. data/app/controllers/dm_core/admin/users_controller.rb +106 -0
  268. data/app/controllers/dm_core/application_controller.rb +253 -0
  269. data/app/controllers/dm_core/concerns/profile_controller.rb +41 -0
  270. data/app/controllers/dm_core/profile_controller.rb +8 -0
  271. data/app/datatables/user_datatable.rb +75 -0
  272. data/app/helpers/devise_helper.rb +25 -0
  273. data/app/helpers/dm_core/account_helper.rb +70 -0
  274. data/app/helpers/dm_core/admin/application_helper.rb +23 -0
  275. data/app/helpers/dm_core/application_helper.rb +58 -0
  276. data/app/helpers/dm_core/liquid_helper.rb +79 -0
  277. data/app/helpers/dm_core/params_helper.rb +19 -0
  278. data/app/helpers/dm_core/render_helper.rb +104 -0
  279. data/app/helpers/dm_core/url_helper.rb +189 -0
  280. data/app/helpers/dm_utilities/currency_helper.rb +24 -0
  281. data/app/helpers/dm_utilities/date_helper.rb +72 -0
  282. data/app/inputs/code_editor_input.rb +51 -0
  283. data/app/inputs/text_full_width_input.rb +9 -0
  284. data/app/inputs/toggle_checked_input.rb +9 -0
  285. data/app/inputs/toggle_input.rb +9 -0
  286. data/app/mailers/dm_core/site_mailer.rb +18 -0
  287. data/app/models/account.rb +241 -0
  288. data/app/models/activity.rb +10 -0
  289. data/app/models/address.rb +24 -0
  290. data/app/models/category.rb +18 -0
  291. data/app/models/comment.rb +24 -0
  292. data/app/models/custom_field.rb +99 -0
  293. data/app/models/custom_field_def.rb +61 -0
  294. data/app/models/dm_core/concerns/ability.rb +17 -0
  295. data/app/models/dm_core/concerns/defines_custom_fields.rb +17 -0
  296. data/app/models/dm_core/concerns/friendly_id.rb +57 -0
  297. data/app/models/dm_core/concerns/has_custom_fields.rb +28 -0
  298. data/app/models/dm_core/concerns/public_private.rb +151 -0
  299. data/app/models/dm_core/concerns/user.rb +144 -0
  300. data/app/models/dm_core/concerns/user_profile.rb +113 -0
  301. data/app/models/dm_core/concerns/user_site_profile.rb +65 -0
  302. data/app/models/dm_core/country.rb +8 -0
  303. data/app/models/dm_core/language.rb +59 -0
  304. data/app/models/dm_core/permitted_params.rb +52 -0
  305. data/app/models/follow.rb +13 -0
  306. data/app/models/liquid_validator.rb +26 -0
  307. data/app/models/payment_history.rb +57 -0
  308. data/app/models/presence_default_locale_validator.rb +12 -0
  309. data/app/models/role.rb +12 -0
  310. data/app/models/system_email.rb +15 -0
  311. data/app/models/ultracart/notification.rb +107 -0
  312. data/app/models/ultracart/payment_history.rb +55 -0
  313. data/app/models/user.rb +22 -0
  314. data/app/models/user_profile.rb +9 -0
  315. data/app/models/user_site_profile.rb +11 -0
  316. data/app/presenters/base_presenter.rb +30 -0
  317. data/app/presenters/comment_presenter.rb +20 -0
  318. data/app/presenters/user_presenter.rb +48 -0
  319. data/app/uploaders/avatar_uploader.rb +75 -0
  320. data/app/views/devise/mailer/confirmation_instructions.html.erb +7 -0
  321. data/app/views/devise/mailer/confirmation_instructions.text.erb +7 -0
  322. data/app/views/devise/mailer/reset_password_instructions.html.erb +9 -0
  323. data/app/views/devise/mailer/reset_password_instructions.text.erb +9 -0
  324. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  325. data/app/views/devise/mailer/unlock_instructions.text.erb +7 -0
  326. data/app/views/dm_core/admin/accounts/_settings_menu.html.erb +24 -0
  327. data/app/views/dm_core/admin/accounts/analytics.html.erb +38 -0
  328. data/app/views/dm_core/admin/accounts/email.html.erb +26 -0
  329. data/app/views/dm_core/admin/accounts/general.html.erb +22 -0
  330. data/app/views/dm_core/admin/accounts/media.html.erb +37 -0
  331. data/app/views/dm_core/admin/accounts/metadata.html.erb +22 -0
  332. data/app/views/dm_core/admin/comments/_comment.html.erb +14 -0
  333. data/app/views/dm_core/admin/comments/_comment_edit_form.html.erb +3 -0
  334. data/app/views/dm_core/admin/comments/_comment_form.html.erb +15 -0
  335. data/app/views/dm_core/admin/comments/_comment_list.html.erb +5 -0
  336. data/app/views/dm_core/admin/comments/_comment_section.html.erb +7 -0
  337. data/app/views/dm_core/admin/comments/create.js.erb +4 -0
  338. data/app/views/dm_core/admin/comments/destroy.js.erb +1 -0
  339. data/app/views/dm_core/admin/comments/edit.js.erb +2 -0
  340. data/app/views/dm_core/admin/comments/update.js.erb +2 -0
  341. data/app/views/dm_core/admin/custom_fields/_check_box_collection.html.erb +4 -0
  342. data/app/views/dm_core/admin/custom_fields/_custom_field_def_fields.html.erb +34 -0
  343. data/app/views/dm_core/admin/custom_fields/_divider.html.erb +1 -0
  344. data/app/views/dm_core/admin/custom_fields/_number_field.html.erb +4 -0
  345. data/app/views/dm_core/admin/custom_fields/_radio_buttons.html.erb +4 -0
  346. data/app/views/dm_core/admin/custom_fields/_select.html.erb +4 -0
  347. data/app/views/dm_core/admin/custom_fields/_text_area.html.erb +4 -0
  348. data/app/views/dm_core/admin/custom_fields/_text_field.html.erb +4 -0
  349. data/app/views/dm_core/admin/dashboard/_index_sidebar.html.erb +22 -0
  350. data/app/views/dm_core/admin/dashboard/_widget_recent_new_users.html.erb +23 -0
  351. data/app/views/dm_core/admin/dashboard/_widget_recent_user_activity.html.erb +21 -0
  352. data/app/views/dm_core/admin/dashboard/index.html.erb +7 -0
  353. data/app/views/dm_core/admin/dashboard/update_site_assets.html.erb +5 -0
  354. data/app/views/dm_core/admin/shared/_header_stats_new_users.html.erb +2 -0
  355. data/app/views/dm_core/admin/shared/_header_stats_user_activity.html.erb +2 -0
  356. data/app/views/dm_core/admin/system/show.html.erb +23 -0
  357. data/app/views/dm_core/admin/users/_form.html.erb +44 -0
  358. data/app/views/dm_core/admin/users/edit.html.erb +201 -0
  359. data/app/views/dm_core/admin/users/index.html.erb +30 -0
  360. data/app/views/dm_core/profile/_profile_sidebar.html.erb +6 -0
  361. data/app/views/dm_core/profile/account.html.erb +38 -0
  362. data/app/views/dm_core/profile/details.html.erb +38 -0
  363. data/app/views/layouts/dm_core/application.html.erb +14 -0
  364. data/app/views/layouts/dm_core/maintenance.html.erb +31 -0
  365. data/app/views/layouts/email_templates/default_email_layout.html.erb +289 -0
  366. data/config/initializers/_dm_core.rb +7 -0
  367. data/config/initializers/carrierwave.rb +33 -0
  368. data/config/initializers/devise.rb +252 -0
  369. data/config/initializers/friendly_id.rb +88 -0
  370. data/config/initializers/globalize_easy_accessors.rb +67 -0
  371. data/config/initializers/globalize_papertrail_fix.rb +20 -0
  372. data/config/initializers/globalize_reflections.rb +22 -0
  373. data/config/initializers/rolify.rb +8 -0
  374. data/config/initializers/simple_form.rb +161 -0
  375. data/config/initializers/simple_form_amsterdam.rb +31 -0
  376. data/config/initializers/simple_form_bootstrap.rb +87 -0
  377. data/config/initializers/simple_form_bootstrap3.rb +175 -0
  378. data/config/initializers/will_paginate.rb +87 -0
  379. data/config/locales/custom.cs.yml +82 -0
  380. data/config/locales/custom.de.yml +82 -0
  381. data/config/locales/custom.en.yml +84 -0
  382. data/config/locales/custom.fi.yml +84 -0
  383. data/config/locales/custom.ja.yml +84 -0
  384. data/config/locales/devise.cs.yml +70 -0
  385. data/config/locales/devise.de.yml +60 -0
  386. data/config/locales/devise.en.yml +59 -0
  387. data/config/locales/devise.fi.yml +57 -0
  388. data/config/locales/devise.ja.yml +102 -0
  389. data/config/locales/rails.cs.yml +211 -0
  390. data/config/locales/rails.de-AT.yml +203 -0
  391. data/config/locales/rails.de.yml +203 -0
  392. data/config/locales/rails.en-GB.yml +205 -0
  393. data/config/locales/rails.en-IN.yml +205 -0
  394. data/config/locales/rails.en.yml +205 -0
  395. data/config/locales/rails.fi.yml +199 -0
  396. data/config/locales/rails.fr-CH.yml +207 -0
  397. data/config/locales/rails.fr.yml +215 -0
  398. data/config/locales/rails.ja.yml +197 -0
  399. data/config/locales/simple_form.cs.yml +26 -0
  400. data/config/locales/simple_form.de.yml +26 -0
  401. data/config/locales/simple_form.en.yml +26 -0
  402. data/config/locales/simple_form.fi.yml +26 -0
  403. data/config/locales/simple_form.ja.yml +26 -0
  404. data/config/routes.rb +33 -0
  405. data/db/globalize_seed_data.sql +76 -0
  406. data/db/migrate/20121023202117_add_globalize_countries.rb +49 -0
  407. data/db/migrate/20121028125329_devise_create_users.rb +45 -0
  408. data/db/migrate/20121028125831_add_user_fields.rb +13 -0
  409. data/db/migrate/20121028153317_rolify_create_roles.rb +19 -0
  410. data/db/migrate/20121105205634_add_last_access.rb +9 -0
  411. data/db/migrate/20121110213512_create_versions.rb +18 -0
  412. data/db/migrate/20121110213513_add_object_changes_column_to_versions.rb +11 -0
  413. data/db/migrate/20130206121535_create_dm_core_accounts.rb +12 -0
  414. data/db/migrate/20130206223323_add_account_to_users.rb +8 -0
  415. data/db/migrate/20130207170247_create_preferences.rb +12 -0
  416. data/db/migrate/20130321144726_create_comments.rb +21 -0
  417. data/db/migrate/20130402203739_add_activity.rb +20 -0
  418. data/db/migrate/20130415095617_add_type_to_comments.rb +8 -0
  419. data/db/migrate/20130429191051_add_category.rb +27 -0
  420. data/db/migrate/20130513112751_create_email_table.rb +25 -0
  421. data/db/migrate/20130516143539_add_user_profile.rb +45 -0
  422. data/db/migrate/20130518155712_add_profile_email.rb +13 -0
  423. data/db/migrate/20130620145610_create_payment_history.rb +36 -0
  424. data/db/migrate/20130625091108_change_anchor_field.rb +9 -0
  425. data/db/migrate/20130628112848_create_user_site_profile.rb +26 -0
  426. data/db/migrate/20130708150236_add_avatar.rb +11 -0
  427. data/db/migrate/20130914132041_add_notify_to_payment_history.rb +7 -0
  428. data/db/migrate/20140105133446_acts_as_votable_migration.rb +27 -0
  429. data/db/migrate/20140107112418_add_user_site_profile_uuid.rb +18 -0
  430. data/db/migrate/20140129110547_add_invoice_id.rb +6 -0
  431. data/db/migrate/20140201092656_acts_as_follower_migration.rb +17 -0
  432. data/db/migrate/20140203131320_rename_invoice_id.rb +11 -0
  433. data/db/migrate/20140210195143_add_core_addresses.rb +17 -0
  434. data/db/migrate/20140411190454_papertrail_increase_column.rb +8 -0
  435. data/db/migrate/20140501160009_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
  436. data/db/migrate/20140501160010_add_missing_unique_indices.acts_as_taggable_on_engine.rb +22 -0
  437. data/db/migrate/20140501160011_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  438. data/db/migrate/20140529164730_create_custom_fields.rb +39 -0
  439. data/db/migrate/20140709145503_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  440. data/db/migrate/20141216094639_add_favored_locale.rb +18 -0
  441. data/db/migrate/20160128094739_update_papertrail_v4.rb +73 -0
  442. data/db/migrate/20160630095745_create_delayed_jobs.rb +22 -0
  443. data/db/migrate/20160821150111_index_foreign_keys_in_core_accounts.rb +5 -0
  444. data/db/migrate/20160821150113_index_foreign_keys_in_core_addresses.rb +5 -0
  445. data/db/migrate/20160821150114_index_foreign_keys_in_core_categories.rb +5 -0
  446. data/db/migrate/20160821150115_index_foreign_keys_in_core_comments.rb +5 -0
  447. data/db/migrate/20160821150116_index_foreign_keys_in_core_custom_fields.rb +5 -0
  448. data/db/migrate/20160821150117_index_foreign_keys_in_core_payment_histories.rb +7 -0
  449. data/db/migrate/20160821150118_index_foreign_keys_in_core_system_email_translations.rb +5 -0
  450. data/db/migrate/20160821150119_index_foreign_keys_in_core_system_emails.rb +6 -0
  451. data/db/migrate/20160821150128_index_foreign_keys_in_preferences.rb +5 -0
  452. data/db/migrate/20160821150129_index_foreign_keys_in_roles.rb +5 -0
  453. data/db/migrate/20160821150130_index_foreign_keys_in_taggings.rb +5 -0
  454. data/db/migrate/20160821150131_index_foreign_keys_in_user_profiles.rb +7 -0
  455. data/db/migrate/20160821150132_index_foreign_keys_in_user_site_profiles.rb +6 -0
  456. data/db/migrate/20160821150133_index_foreign_keys_in_users_roles.rb +5 -0
  457. data/db/migrate/20160821150134_index_foreign_keys_in_version_associations.rb +5 -0
  458. data/db/migrate/20160821150135_index_foreign_keys_in_versions.rb +5 -0
  459. data/db/seeds.rb +433 -0
  460. data/db/seeds/globalize_countries.rb +239 -0
  461. data/db/seeds/globalize_languages.rb +186 -0
  462. data/lib/dm_core.rb +38 -0
  463. data/lib/dm_core/csv_exporter.rb +210 -0
  464. data/lib/dm_core/csv_importer.rb +16 -0
  465. data/lib/dm_core/engine.rb +51 -0
  466. data/lib/dm_core/liquid_extensions.rb +125 -0
  467. data/lib/dm_core/nls.rb +31 -0
  468. data/lib/dm_core/scio_excel.rb +501 -0
  469. data/lib/dm_core/state_select.rb +135 -0
  470. data/lib/dm_core/version.rb +3 -0
  471. data/lib/tasks/dm_core_tasks.rake +60 -0
  472. data/spec/dummy/README.rdoc +28 -0
  473. data/spec/dummy/Rakefile +6 -0
  474. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  475. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  476. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  477. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  478. data/spec/dummy/app/models/ability.rb +10 -0
  479. data/spec/dummy/app/models/user.rb +6 -0
  480. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  481. data/spec/dummy/bin/bundle +3 -0
  482. data/spec/dummy/bin/rails +4 -0
  483. data/spec/dummy/bin/rake +4 -0
  484. data/spec/dummy/config.ru +4 -0
  485. data/spec/dummy/config/application.rb +27 -0
  486. data/spec/dummy/config/boot.rb +5 -0
  487. data/spec/dummy/config/database.yml +25 -0
  488. data/spec/dummy/config/environment.rb +5 -0
  489. data/spec/dummy/config/environments/development.rb +37 -0
  490. data/spec/dummy/config/environments/production.rb +82 -0
  491. data/spec/dummy/config/environments/test.rb +39 -0
  492. data/spec/dummy/config/initializers/assets.rb +8 -0
  493. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  494. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  495. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  496. data/spec/dummy/config/initializers/inflections.rb +16 -0
  497. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  498. data/spec/dummy/config/initializers/session_store.rb +3 -0
  499. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  500. data/spec/dummy/config/locales/en.yml +23 -0
  501. data/spec/dummy/config/routes.rb +11 -0
  502. data/spec/dummy/config/secrets.yml +22 -0
  503. data/spec/dummy/db/development.sqlite3 +0 -0
  504. data/spec/dummy/db/schema.rb +399 -0
  505. data/spec/dummy/db/test.sqlite3 +0 -0
  506. data/spec/dummy/log/test.log +374 -0
  507. data/spec/dummy/public/404.html +67 -0
  508. data/spec/dummy/public/422.html +67 -0
  509. data/spec/dummy/public/500.html +66 -0
  510. data/spec/dummy/public/favicon.ico +0 -0
  511. data/spec/factories/accounts.rb +9 -0
  512. data/spec/factories/user_profiles.rb +10 -0
  513. data/spec/factories/users.rb +19 -0
  514. data/spec/helpers/account_helper_spec.rb +50 -0
  515. data/spec/models/account_spec.rb +20 -0
  516. data/spec/models/user_spec.rb +99 -0
  517. data/spec/rails_helper.rb +70 -0
  518. data/spec/spec_helper.rb +85 -0
  519. data/spec/support/accounts.rb +19 -0
  520. data/spec/support/devise.rb +44 -0
  521. data/spec/support/fix_locale.rb +57 -0
  522. metadata +1124 -0
@@ -0,0 +1,13 @@
1
+ class Follow < ActiveRecord::Base
2
+ extend ActsAsFollower::FollowerLib
3
+ extend ActsAsFollower::FollowScopes
4
+
5
+ # NOTE: Follows belong to the "followable" interface, and also to followers
6
+ belongs_to :followable, :polymorphic => true
7
+ belongs_to :follower, :polymorphic => true
8
+
9
+ def block!
10
+ self.update_attribute(:blocked, true)
11
+ end
12
+
13
+ end
@@ -0,0 +1,26 @@
1
+ # Validate whether an attribute has a parsable liquid template.
2
+ # if { locales: true } is passed in, will assume it's a localized
3
+ # field and check all locales
4
+ # validates :content, :liquid => { :locales => true }
5
+ #------------------------------------------------------------------------------
6
+ class LiquidValidator < ActiveModel::EachValidator
7
+ def validate_each(record, attribute, value)
8
+ if options[:locales]
9
+ Account.current.site_locales.each do |locale|
10
+ attribute_locale = "#{attribute.to_s}_#{locale}"
11
+ begin
12
+ Liquid::Template.parse(record.send(attribute_locale))
13
+ rescue Liquid::SyntaxError => e
14
+ record.errors.add attribute_locale, e.message
15
+ end
16
+ end
17
+ else
18
+ begin
19
+ Liquid::Template.parse(value)
20
+ rescue Liquid::SyntaxError => e
21
+ record.errors.add attribute, e.message
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,57 @@
1
+ # anchor_id => unique number tying paid item to our item
2
+ # order_ref => order number
3
+ # item_ref => specfic item number
4
+ # item_name => item's name
5
+ # quantity => number of items
6
+ # cost => cost of item, as a number string (to_f.to_s)
7
+ # discount => any coupon/dicsount
8
+ # total_cents => total amount in cents
9
+ # total_currency => currency 3 char code
10
+ # payment_method => how payment was made: cash, credit card, etc
11
+ # payment_date => date of payment
12
+ # bill_to_name => who actually paid / was billed to
13
+ # item_details => any specific item details sent by payment processor
14
+ # order_details => any specific order details sent by payment processor
15
+ # status => status of payment
16
+ # user_profile_id => user_profile if payment was enetered manually
17
+ # notify_data => data from the notification object, in case it's needed
18
+ #------------------------------------------------------------------------------
19
+ class PaymentHistory < ActiveRecord::Base
20
+
21
+ self.table_name = 'core_payment_histories'
22
+
23
+ belongs_to :owner, :polymorphic => true
24
+ belongs_to :user_profile
25
+ serialize :order_details
26
+ serialize :item_details
27
+ serialize :notify_data
28
+ monetize :total_cents, :with_model_currency => :total_currency, :allow_nil => true
29
+
30
+ default_scope { where(account_id: Account.current.id) }
31
+
32
+ validates_numericality_of :cost
33
+
34
+ # Generate the anchor code that gets placed in a shopping cart item. This is
35
+ # used to gain access to some agreed upon item in the database.
36
+ # Default algorithm: Use the current time as a unique code and append
37
+ # the passed in id
38
+ # Ex: ANC-1158569928-517
39
+ # -> override this function to provide a different algorithm if needed
40
+ #------------------------------------------------------------------------------
41
+ def self.generate_anchor_id(id)
42
+ "ANC-#{Time.now.utc.to_i}-#{id}"
43
+ end
44
+
45
+ # Extract the anchor code that gets placed in a shopping cart item. This is
46
+ # used to gain access to some agreed upon item in the database.
47
+ # Default algorithm: Use the current time as a unique code and append
48
+ # the passed in id
49
+ # -> override this function to provide a different algorithm if needed
50
+ #------------------------------------------------------------------------------
51
+ def self.extract_anchor_id(anchor_id)
52
+ #--- pull off first two pieces, and put rest back together if there were any
53
+ # embedded dashes
54
+ values = anchor_id.split('-')
55
+ return values.slice(2, 10).join('-')
56
+ end
57
+ end
@@ -0,0 +1,12 @@
1
+ # Validate whether the default locale of a translated attribute is present
2
+ # validates :content, presence_default_locale: true
3
+ #------------------------------------------------------------------------------
4
+ class PresenceDefaultLocaleValidator < ActiveModel::EachValidator
5
+ def validate_each(record, attribute, value)
6
+ attribute_locale = "#{attribute.to_s}_#{Account.current.preferred_default_locale}"
7
+ if record.send(attribute_locale).blank?
8
+ record.errors.add attribute_locale, I18n.t("errors.messages.blank")
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,12 @@
1
+ # Dynamic shortcuts should NOT be enabled for this application, as it conflicts with
2
+ # default account scoping
3
+ #------------------------------------------------------------------------------
4
+ class Role < ActiveRecord::Base
5
+
6
+ has_and_belongs_to_many :users, :join_table => :users_roles
7
+ belongs_to :resource, :polymorphic => true
8
+
9
+ scopify
10
+
11
+ default_scope { where(account_id: Account.current.id) }
12
+ end
@@ -0,0 +1,15 @@
1
+ # Generated from acts_as_commentable
2
+ #------------------------------------------------------------------------------
3
+ class SystemEmail < ActiveRecord::Base
4
+
5
+ self.table_name = 'core_system_emails'
6
+
7
+ belongs_to :emailable, :polymorphic => true
8
+
9
+ default_scope { where(account_id: Account.current.id) }
10
+
11
+ # --- globalize
12
+ translates :subject, :body, :fallbacks_for_empty_translations => true
13
+ globalize_accessors :locales => DmCore::Language.language_array
14
+
15
+ end
@@ -0,0 +1,107 @@
1
+ #------------------------------------------------------------------------------
2
+ class Ultracart::Notification
3
+ attr_accessor :order_details, :items, :anchor_ids
4
+
5
+ CURRENT_STAGE_MAPPING = { 'PO' => :pre_order, 'AR' => :account_receivable,
6
+ 'SD' => :shipping, 'REJ' => :rejected,
7
+ 'CO' => :completed_order}
8
+
9
+ #------------------------------------------------------------------------------
10
+ def initialize(notify_params)
11
+
12
+ #--- extract the order details and the items
13
+ @order_details = (notify_params['export']['order'])
14
+ @items = @order_details['item']
15
+ @items = Array.[](@items) if @items.class == HashWithIndifferentAccess or @items.class == Hash
16
+
17
+ #--- remove the items hash from the order, so we can save the order details seperate
18
+ @order_details.delete('item')
19
+
20
+ #--- build up the anchor_ids array
21
+ @anchor_ids = Array.new
22
+ @items.each do |item|
23
+ @anchor_ids << extract_anchor_id(item)
24
+ end
25
+ end
26
+
27
+ # Stage that the order is in
28
+ #------------------------------------------------------------------------------
29
+ def current_stage
30
+ return CURRENT_STAGE_MAPPING[@order_details['current_stage']]
31
+ end
32
+
33
+
34
+ protected
35
+
36
+ #------------------------------------------------------------------------------
37
+ def extract_anchor_id(item)
38
+ anchor = nil
39
+ option_items = item['option']
40
+ option_items = Array.[](option_items) if option_items.class == Hash or option_items.class == HashWithIndifferentAccess
41
+ unless option_items.nil?
42
+ option_items.each do |the_option|
43
+ #if the_option['option_name'] == 'anchor_id'
44
+ anchor = the_option['option_value'] unless the_option['option_value'].blank?
45
+ #end
46
+ end
47
+ end
48
+ return anchor
49
+ end
50
+ end
51
+
52
+ # # This function is called by UltraCart when an item is purchased from the online
53
+ # # store. The entire order is sent. Initially, we will look for the
54
+ # # registration code we place in a ticket order, and mark the appropriate record
55
+ # # as payed in the database. But this also sets up the possibility of keeping
56
+ # # our own purchase records and doing our own reporting.
57
+ # #------------------------------------------------------------------------------
58
+ # def self.verify_payment(current_account, params)
59
+ # #--- the specifics for order have already been parsed into the params block
60
+ # notify = Ultracart::Notification.new(params)
61
+ # @@uclogger.info(Time.now.utc.to_s + ": Order ID => #{notify.order_details['order_id']} " +
62
+ # "Stage => #{notify.order_details['current_stage']} " +
63
+ # "Name => #{notify.order_details['bill_to_first_name']} #{notify.order_details['bill_to_last_name']}"
64
+ # )
65
+ #
66
+ # receipts = Array.new
67
+ #
68
+ # #--- validate the merchant id
69
+ # if notify.order_details['merchant_id'] != current_account.preferred(:ultracart_merchant_id)
70
+ # @@uclogger.info(" ==> Error: merchant_id incorrect: #{notify.order_details['merchant_id']} != #{current_account.preferred(:ultracart_merchant_id)}")
71
+ # @@uclogger.info(params.inspect)
72
+ # else
73
+ # case notify.current_stage
74
+ # when :pre_order, :account_receivable, :shipping, :rejected
75
+ # @@uclogger.info(" Ignored")
76
+ # #--- these are just notifications - do nothing
77
+ # when :completed_order
78
+ # #--- iterate over each item in order
79
+ # notify.items.each_with_index do |item, i|
80
+ # #--- only record notifications that have a registration code
81
+ # unless notify.anchor_ids[i].blank?
82
+ # history = PaymentHistory.create(:notify => notify, :item => item, :anchor_id => notify.anchor_ids[i])
83
+ # history.update_attribute(:total_cents, EventPayment.payment_total_cents(history.cost, history.quantity, history.discount))
84
+ # history.update_attribute(:owner_type, 'EventRegistration')
85
+ # history.update_attribute(:owner_id, EventRegistration.receiptcode_to_id(history.anchor_id))
86
+ # @@uclogger.info(" item_id => #{history.item_id} anchor_id => #{history.anchor_id}")
87
+ #
88
+ # if history.anchor_id
89
+ # #--- check if there is a valid user
90
+ # event = EventRegistration.find_by_receiptcode(history.anchor_id)
91
+ # if event.nil?
92
+ # @@uclogger.info(" ==> Error: invalid registration id => #{history.anchor_id}")
93
+ # @@uclogger.info(params.inspect)
94
+ # else
95
+ # history.update_attribute(:currency_country_id, event.event_payment.country_id)
96
+ # event.mark_paid(history.total_cents)
97
+ # event.add_comment(Comment.new(:comment => "[coupon_code: #{history.coupon_code}] ")) unless history.coupon_code.blank?
98
+ # receipts << {:receiptcode => history.anchor_id, :cost_cents => history.total_cents, :description => history.item_name}
99
+ # end
100
+ # end
101
+ # end
102
+ # end
103
+ # end
104
+ # end
105
+ #
106
+ # return receipts
107
+ # end
@@ -0,0 +1,55 @@
1
+ # Integration with the Ultracart shopping cart (ultracart.com)
2
+ #------------------------------------------------------------------------------
3
+ class Ultracart::PaymentHistory < PaymentHistory
4
+
5
+ # Params: :notify, :item, :anchor_id
6
+ #------------------------------------------------------------------------------
7
+ def initialize(params, options)
8
+ init_params = Hash.new
9
+ notify = params[:notify]
10
+ item = params[:item]
11
+ anchor_id = params[:anchor_id]
12
+
13
+ #--- extract the relevant data
14
+ init_params[:order_ref] = notify.order_details['order_id']
15
+ init_params[:payment_method] = notify.order_details['payment_method']
16
+ init_params[:payment_date] = Time.parse(notify.order_details['payment_date_time']).utc unless notify.order_details['payment_date_time'].nil?
17
+ init_params[:bill_to_name] = notify.order_details['bill_to_first_name'] + ' ' + notify.order_details['bill_to_last_name']
18
+ init_params[:current_stage] = notify.current_stage.to_s
19
+ init_params[:order_details] = notify.order_details
20
+ init_params[:item_details] = item
21
+ if item
22
+ init_params[:item_ref] = item['item_id']
23
+ init_params[:cost] = item['cost']
24
+ init_params[:discount] = item['discount']
25
+ init_params[:quantity] = item['quantity'].to_i
26
+ init_params[:item_name] = item['description']
27
+ init_params[:anchor_id] = PaymentHistory.extract_anchor_id(anchor_id) unless anchor_id.blank?
28
+ end
29
+ super(init_params, options)
30
+ end
31
+
32
+ #------------------------------------------------------------------------------
33
+ def get_option_value(name)
34
+ value = nil
35
+ option_items = item_details['option']
36
+ option_items = Array.[](option_items) if option_items.class == Hash or option_items.class == HashWithIndifferentAccess
37
+ unless option_items.nil?
38
+ option_items.each do |the_option|
39
+ if the_option['option_name'] == name
40
+ value = the_option['option_value'] unless the_option['option_value'].blank?
41
+ end
42
+ end
43
+ end
44
+ return value
45
+ end
46
+
47
+ #------------------------------------------------------------------------------
48
+ def coupon_code
49
+ if order_details.nil? or order_details['coupon'].nil?
50
+ ''
51
+ else
52
+ order_details['coupon']['coupon_code']
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ # users, user_profiles, and user_site_profiles...
2
+ #
3
+ # User:
4
+ # There is one User per person/email address. Email address is the primary key.
5
+ # A User is created for a specific account. However, that user can login to any
6
+ # of the hosted sites on this system, with the same user/pass. In this way
7
+ # we can have a set of related sites, with single sign-on
8
+ #
9
+ # UserProfile:
10
+ # Only one per User, this contains all the profile information - name, address,
11
+ # public/private avatars. This information is used across all sites.
12
+ #
13
+ # UserSiteProfile:
14
+ # A User has one of these for each site they have logged into. Keeps track of
15
+ # any site specific information, like the last_access_at field, etc. Also
16
+ # allows us to know if someone has ever logged into a specific site.
17
+ #------------------------------------------------------------------------------
18
+ class User < ActiveRecord::Base
19
+
20
+ include DmCore::Concerns::User
21
+
22
+ end
@@ -0,0 +1,9 @@
1
+ # This holds the profile data for a user. There is only one instance per user,
2
+ # so even when we're using users across sites, there is only one profile record
3
+ # per user record.
4
+ #------------------------------------------------------------------------------
5
+ class UserProfile < ActiveRecord::Base
6
+
7
+ include DmCore::Concerns::UserProfile
8
+
9
+ end
@@ -0,0 +1,11 @@
1
+ # This holds a site profile for a user. This is any data that is needed for
2
+ # a user, on a per site/account basis, such as site specific preferences, login times,
3
+ # etc.
4
+ # Note: don't use a default account scope as it makes some of the User
5
+ # associations a little more difficult
6
+ #------------------------------------------------------------------------------
7
+ class UserSiteProfile < ActiveRecord::Base
8
+
9
+ include DmCore::Concerns::UserSiteProfile
10
+
11
+ end
@@ -0,0 +1,30 @@
1
+ # Based on the Railscast: http://railscasts.com/episodes/287-presenters-from-scratch
2
+ #------------------------------------------------------------------------------
3
+ class BasePresenter
4
+ include DmCore::LiquidHelper
5
+
6
+ #------------------------------------------------------------------------------
7
+ def initialize(object, template)
8
+ @object = object
9
+ @template = template
10
+ end
11
+
12
+ private
13
+
14
+ #------------------------------------------------------------------------------
15
+ def self.presents(name)
16
+ define_method(name) do
17
+ @object
18
+ end
19
+ end
20
+
21
+ #------------------------------------------------------------------------------
22
+ def h
23
+ @template
24
+ end
25
+
26
+ #------------------------------------------------------------------------------
27
+ def method_missing(*args, &block)
28
+ @template.send(*args, &block)
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ class CommentPresenter < BasePresenter
2
+
3
+ presents :comment
4
+
5
+ #------------------------------------------------------------------------------
6
+ def formatted_comment
7
+ markdown(comment.body, :safe => true)
8
+ end
9
+
10
+ #------------------------------------------------------------------------------
11
+ def date_posted
12
+ format_datetime comment.created_at
13
+ end
14
+
15
+ #------------------------------------------------------------------------------
16
+ def author
17
+ comment.user.nil? ? 'Anonymous' : comment.user.display_name
18
+ end
19
+
20
+ end
@@ -0,0 +1,48 @@
1
+ class UserPresenter < BasePresenter
2
+
3
+ presents :user
4
+ #delegate :username, to: :user
5
+
6
+ #------------------------------------------------------------------------------
7
+ def role_label
8
+ if user.is_admin?
9
+ colored_label('Admin', :success)
10
+ elsif user.has_role?(:manager)
11
+ colored_label('Manager', :info)
12
+ elsif user.has_role?(:content_manager) || user.has_role?(:event_manager) || user.has_role?(:forum_manager)
13
+ colored_label('Submanager', :warning)
14
+ elsif user.has_role?(:reviewer)
15
+ colored_label('Reviewer', :default)
16
+ elsif user.has_role?(:beta)
17
+ colored_label('Beta', :danger)
18
+ else
19
+ 'User'
20
+ end
21
+ end
22
+
23
+ #------------------------------------------------------------------------------
24
+ def last_access
25
+ user.last_access_at.nil? ? colored_label('n/a', :warning) : "#{time_ago_in_words(user.last_access_at)} ago"
26
+ end
27
+
28
+ # gives the public avatar for a user
29
+ #------------------------------------------------------------------------------
30
+ def avatar_for(size = 32)
31
+ case
32
+ when size.class == String && size.end_with?('%')
33
+ avatar = user.user_profile.public_avatar_url(:sq200)
34
+ when size <= 35
35
+ avatar = user.user_profile.public_avatar_url(:sq35)
36
+ when size <= 100
37
+ avatar = user.user_profile.public_avatar_url(:sq100)
38
+ when size <= 200
39
+ avatar = user.user_profile.public_avatar_url(:sq200)
40
+ else
41
+ avatar = user.user_profile.public_avatar_url
42
+ end
43
+ # image_tag('dm_core/user.gif', width: size, height: size, class: 'image')
44
+ image_tag(avatar, width: size, class: 'image')
45
+ end
46
+
47
+
48
+ end