From 29cd8804809c3abbaed57071c603f6efd8d9b398 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Thu, 7 Apr 2016 09:40:53 -0700 Subject: [PATCH] Refactor handlers to /server/handlers --- scripts/buildSchoolGraph.coffee | 2 +- scripts/recalculateAchievements.coffee | 2 +- scripts/recalculatePayments.coffee | 2 +- scripts/recalculateStatistics.coffee | 2 +- scripts/resetUsersProgress.coffee | 2 +- server/commons/mapping.coffee | 60 +++++++++---------- .../achievement_handler.coffee | 0 .../analytics_log_event_handler.coffee | 0 .../analytics_perday_handler.coffee | 0 .../analytics_string_handler.coffee | 0 .../analytics_stripe_invoice_handler.coffee | 0 .../analytics_users_active_handler.coffee | 0 .../article_handler.coffee | 0 .../campaign_handler.coffee | 0 .../{clans => handlers}/clan_handler.coffee | 6 +- .../classroom_handler.coffee | 2 +- .../course_instance_handler.coffee | 6 +- .../discount_handler.coffee | 0 .../earned_achievement_handler.coffee | 0 .../level_component_handler.coffee | 6 +- .../level_feedback_handler.coffee | 6 +- .../{levels => handlers}/level_handler.coffee | 2 +- .../level_session_handler.coffee | 4 +- .../level_system_handler.coffee | 6 +- .../mail_sent_handler.coffee | 6 +- .../patch_handler.coffee | 0 .../payment_handler.coffee | 0 .../{polls => handlers}/poll_handler.coffee | 0 .../prepaid_handler.coffee | 0 .../purchase_handler.coffee | 0 .../subscription_handler.coffee | 0 .../thang_type_handler.coffee | 6 +- .../user_code_problem_handler.coffee | 0 .../{users => handlers}/user_handler.coffee | 8 +-- .../user_polls_record_handler.coffee | 0 .../user_remark_handler.coffee | 6 +- server/lib/stripe_utils.coffee | 2 +- .../remarks => models}/UserRemark.coffee | 4 +- server/routes/auth.coffee | 2 +- server/routes/mail.coffee | 2 +- server_setup.coffee | 4 +- .../server/functional/achievement.spec.coffee | 2 +- spec/server/functional/patch.spec.coffee | 2 +- spec/server/functional/user.spec.coffee | 2 +- 44 files changed, 77 insertions(+), 77 deletions(-) rename server/{achievements => handlers}/achievement_handler.coffee (100%) rename server/{analytics => handlers}/analytics_log_event_handler.coffee (100%) rename server/{analytics => handlers}/analytics_perday_handler.coffee (100%) rename server/{analytics => handlers}/analytics_string_handler.coffee (100%) rename server/{analytics => handlers}/analytics_stripe_invoice_handler.coffee (100%) rename server/{analytics => handlers}/analytics_users_active_handler.coffee (100%) rename server/{articles => handlers}/article_handler.coffee (100%) rename server/{campaigns => handlers}/campaign_handler.coffee (100%) rename server/{clans => handlers}/clan_handler.coffee (97%) rename server/{classrooms => handlers}/classroom_handler.coffee (99%) rename server/{courses => handlers}/course_instance_handler.coffee (98%) rename server/{payments => handlers}/discount_handler.coffee (100%) rename server/{achievements => handlers}/earned_achievement_handler.coffee (100%) rename server/{levels/components => handlers}/level_component_handler.coffee (90%) rename server/{levels/feedbacks => handlers}/level_feedback_handler.coffee (68%) rename server/{levels => handlers}/level_handler.coffee (99%) rename server/{levels/sessions => handlers}/level_session_handler.coffee (96%) rename server/{levels/systems => handlers}/level_system_handler.coffee (81%) rename server/{mail/sent => handlers}/mail_sent_handler.coffee (57%) rename server/{patches => handlers}/patch_handler.coffee (100%) rename server/{payments => handlers}/payment_handler.coffee (100%) rename server/{polls => handlers}/poll_handler.coffee (100%) rename server/{prepaids => handlers}/prepaid_handler.coffee (100%) rename server/{purchases => handlers}/purchase_handler.coffee (100%) rename server/{payments => handlers}/subscription_handler.coffee (100%) rename server/{levels/thangs => handlers}/thang_type_handler.coffee (95%) rename server/{user_code_problems => handlers}/user_code_problem_handler.coffee (100%) rename server/{users => handlers}/user_handler.coffee (99%) rename server/{polls => handlers}/user_polls_record_handler.coffee (100%) rename server/{users/remarks => handlers}/user_remark_handler.coffee (62%) rename server/{users/remarks => models}/UserRemark.coffee (72%) diff --git a/scripts/buildSchoolGraph.coffee b/scripts/buildSchoolGraph.coffee index ea039d2c7..9b04b7657 100644 --- a/scripts/buildSchoolGraph.coffee +++ b/scripts/buildSchoolGraph.coffee @@ -17,7 +17,7 @@ do (setupLodash = this) -> database.connect() -UserHandler = require '../server/users/user_handler' +UserHandler = require '../server/handlers/user_handler' User = require '../server/models/User' startDate = new Date 2015, 11, 1 diff --git a/scripts/recalculateAchievements.coffee b/scripts/recalculateAchievements.coffee index b18495f7d..e1b83d09d 100644 --- a/scripts/recalculateAchievements.coffee +++ b/scripts/recalculateAchievements.coffee @@ -12,7 +12,7 @@ do (setupLodash = this) -> database.connect() -EarnedAchievementHandler = require '../server/achievements/earned_achievement_handler' +EarnedAchievementHandler = require '../server/handlers/earned_achievement_handler' log.info 'Starting earned achievement recalculation...' EarnedAchievementHandler.constructor.recalculate (err) -> log.error err if err? diff --git a/scripts/recalculatePayments.coffee b/scripts/recalculatePayments.coffee index becf3e74e..e78004f1b 100644 --- a/scripts/recalculatePayments.coffee +++ b/scripts/recalculatePayments.coffee @@ -14,7 +14,7 @@ database.connect() User = require '../server/models/User' Payment = require '../server/models/Payment' -PaymentHandler = require '../server/payments/payment_handler' +PaymentHandler = require '../server/handlers/payment_handler' t0 = new Date().getTime() total = 100000 diff --git a/scripts/recalculateStatistics.coffee b/scripts/recalculateStatistics.coffee index a23551085..1ee68c5bb 100644 --- a/scripts/recalculateStatistics.coffee +++ b/scripts/recalculateStatistics.coffee @@ -12,7 +12,7 @@ do (setupLodash = this) -> database.connect() ### USER STATS ### -UserHandler = require '../server/users/user_handler' +UserHandler = require '../server/handlers/user_handler' report = (func, name, done) -> log.info 'Started ' + name + '...' diff --git a/scripts/resetUsersProgress.coffee b/scripts/resetUsersProgress.coffee index 7c6e07ea9..72b002434 100644 --- a/scripts/resetUsersProgress.coffee +++ b/scripts/resetUsersProgress.coffee @@ -14,7 +14,7 @@ do (setupLodash = this) -> database.connect() -UserHandler = require '../server/users/user_handler' +UserHandler = require '../server/handlers/user_handler' User = require '../server/models/User' userIDs = [ diff --git a/server/commons/mapping.coffee b/server/commons/mapping.coffee index c3fdee0ac..9b1c22bd2 100644 --- a/server/commons/mapping.coffee +++ b/server/commons/mapping.coffee @@ -1,35 +1,35 @@ module.exports.handlers = - 'analytics_log_event': 'analytics/analytics_log_event_handler' - 'analytics_perday': 'analytics/analytics_perday_handler' - 'analytics_string': 'analytics/analytics_string_handler' - 'analytics_stripe_invoice': 'analytics/analytics_stripe_invoice_handler' + 'analytics_log_event': 'handlers/analytics_log_event_handler' + 'analytics_perday': 'handlers/analytics_perday_handler' + 'analytics_string': 'handlers/analytics_string_handler' + 'analytics_stripe_invoice': 'handlers/analytics_stripe_invoice_handler' # TODO: Disabling this until we know why our app servers CPU grows out of control. - # 'analytics_users_active': 'analytics/analytics_users_active_handler' - 'article': 'articles/article_handler' - 'campaign': 'campaigns/campaign_handler' - 'clan': 'clans/clan_handler' - 'classroom': 'classrooms/classroom_handler' - 'course': 'courses/course_handler' - 'course_instance': 'courses/course_instance_handler' - 'level': 'levels/level_handler' - 'level_component': 'levels/components/level_component_handler' - 'level_feedback': 'levels/feedbacks/level_feedback_handler' - 'level_session': 'levels/sessions/level_session_handler' - 'level_system': 'levels/systems/level_system_handler' - 'patch': 'patches/patch_handler' - 'payment': 'payments/payment_handler' - 'purchase': 'purchases/purchase_handler' - 'thang_type': 'levels/thangs/thang_type_handler' - 'user': 'users/user_handler' - 'user_code_problem': 'user_code_problems/user_code_problem_handler' - 'user_remark': 'users/remarks/user_remark_handler' - 'mail_sent': 'mail/sent/mail_sent_handler' - 'achievement': 'achievements/achievement_handler' - 'earned_achievement': 'achievements/earned_achievement_handler' - 'poll': 'polls/poll_handler' - 'prepaid': 'prepaids/prepaid_handler' - 'subscription': 'payments/subscription_handler' - 'user_polls_record': 'polls/user_polls_record_handler' + # 'analytics_users_active': 'handlers/analytics_users_active_handler' + 'article': 'handlers/article_handler' + 'campaign': 'handlers/campaign_handler' + 'clan': 'handlers/clan_handler' + 'classroom': 'handlers/classroom_handler' + 'course': 'handlers/course_handler' + 'course_instance': 'handlers/course_instance_handler' + 'level': 'handlers/level_handler' + 'level_component': 'handlers/level_component_handler' + 'level_feedback': 'handlers/level_feedback_handler' + 'level_session': 'handlers/level_session_handler' + 'level_system': 'handlers/level_system_handler' + 'patch': 'handlers/patch_handler' + 'payment': 'handlers/payment_handler' + 'purchase': 'handlers/purchase_handler' + 'thang_type': 'handlers/thang_type_handler' + 'user': 'handlers/user_handler' + 'user_code_problem': 'handlers/user_code_problem_handler' + 'user_remark': 'handlers/user_remark_handler' + 'mail_sent': 'handlers/mail_sent_handler' + 'achievement': 'handlers/achievement_handler' + 'earned_achievement': 'handlers/earned_achievement_handler' + 'poll': 'handlers/poll_handler' + 'prepaid': 'handlers/prepaid_handler' + 'subscription': 'handlers/subscription_handler' + 'user_polls_record': 'handlers/user_polls_record_handler' module.exports.handlerUrlOverrides = 'analytics_log_event': 'analytics.log.event' diff --git a/server/achievements/achievement_handler.coffee b/server/handlers/achievement_handler.coffee similarity index 100% rename from server/achievements/achievement_handler.coffee rename to server/handlers/achievement_handler.coffee diff --git a/server/analytics/analytics_log_event_handler.coffee b/server/handlers/analytics_log_event_handler.coffee similarity index 100% rename from server/analytics/analytics_log_event_handler.coffee rename to server/handlers/analytics_log_event_handler.coffee diff --git a/server/analytics/analytics_perday_handler.coffee b/server/handlers/analytics_perday_handler.coffee similarity index 100% rename from server/analytics/analytics_perday_handler.coffee rename to server/handlers/analytics_perday_handler.coffee diff --git a/server/analytics/analytics_string_handler.coffee b/server/handlers/analytics_string_handler.coffee similarity index 100% rename from server/analytics/analytics_string_handler.coffee rename to server/handlers/analytics_string_handler.coffee diff --git a/server/analytics/analytics_stripe_invoice_handler.coffee b/server/handlers/analytics_stripe_invoice_handler.coffee similarity index 100% rename from server/analytics/analytics_stripe_invoice_handler.coffee rename to server/handlers/analytics_stripe_invoice_handler.coffee diff --git a/server/analytics/analytics_users_active_handler.coffee b/server/handlers/analytics_users_active_handler.coffee similarity index 100% rename from server/analytics/analytics_users_active_handler.coffee rename to server/handlers/analytics_users_active_handler.coffee diff --git a/server/articles/article_handler.coffee b/server/handlers/article_handler.coffee similarity index 100% rename from server/articles/article_handler.coffee rename to server/handlers/article_handler.coffee diff --git a/server/campaigns/campaign_handler.coffee b/server/handlers/campaign_handler.coffee similarity index 100% rename from server/campaigns/campaign_handler.coffee rename to server/handlers/campaign_handler.coffee diff --git a/server/clans/clan_handler.coffee b/server/handlers/clan_handler.coffee similarity index 97% rename from server/clans/clan_handler.coffee rename to server/handlers/clan_handler.coffee index 84cbf4a69..b76bdc72c 100644 --- a/server/clans/clan_handler.coffee +++ b/server/handlers/clan_handler.coffee @@ -4,11 +4,11 @@ Handler = require '../commons/Handler' AnalyticsLogEvent = require '../models/AnalyticsLogEvent' Clan = require './../models/Clan' EarnedAchievement = require '../models/EarnedAchievement' -EarnedAchievementHandler = require '../achievements/earned_achievement_handler' +EarnedAchievementHandler = require './earned_achievement_handler' LevelSession = require '../models/LevelSession' -LevelSessionHandler = require '../levels/sessions/level_session_handler' +LevelSessionHandler = require './level_session_handler' User = require '../models/User' -UserHandler = require '../users/user_handler' +UserHandler = require './user_handler' memberLimit = 200 diff --git a/server/classrooms/classroom_handler.coffee b/server/handlers/classroom_handler.coffee similarity index 99% rename from server/classrooms/classroom_handler.coffee rename to server/handlers/classroom_handler.coffee index 149fe3c9b..69008e018 100644 --- a/server/classrooms/classroom_handler.coffee +++ b/server/handlers/classroom_handler.coffee @@ -5,7 +5,7 @@ Classroom = require './../models/Classroom' User = require '../models/User' sendwithus = require '../sendwithus' utils = require '../lib/utils' -UserHandler = require '../users/user_handler' +UserHandler = require './user_handler' ClassroomHandler = class ClassroomHandler extends Handler modelClass: Classroom diff --git a/server/courses/course_instance_handler.coffee b/server/handlers/course_instance_handler.coffee similarity index 98% rename from server/courses/course_instance_handler.coffee rename to server/handlers/course_instance_handler.coffee index 6c7a425cc..94e3951f8 100644 --- a/server/courses/course_instance_handler.coffee +++ b/server/handlers/course_instance_handler.coffee @@ -5,11 +5,11 @@ Classroom = require '../models/Classroom' Course = require '../models/Course' CourseInstance = require './../models/CourseInstance' LevelSession = require '../models/LevelSession' -LevelSessionHandler = require '../levels/sessions/level_session_handler' +LevelSessionHandler = require './level_session_handler' Prepaid = require '../models/Prepaid' -PrepaidHandler = require '../prepaids/prepaid_handler' +PrepaidHandler = require './prepaid_handler' User = require '../models/User' -UserHandler = require '../users/user_handler' +UserHandler = require './user_handler' utils = require '../../app/core/utils' {objectIdFromTimestamp} = require '../lib/utils' sendwithus = require '../sendwithus' diff --git a/server/payments/discount_handler.coffee b/server/handlers/discount_handler.coffee similarity index 100% rename from server/payments/discount_handler.coffee rename to server/handlers/discount_handler.coffee diff --git a/server/achievements/earned_achievement_handler.coffee b/server/handlers/earned_achievement_handler.coffee similarity index 100% rename from server/achievements/earned_achievement_handler.coffee rename to server/handlers/earned_achievement_handler.coffee diff --git a/server/levels/components/level_component_handler.coffee b/server/handlers/level_component_handler.coffee similarity index 90% rename from server/levels/components/level_component_handler.coffee rename to server/handlers/level_component_handler.coffee index e68b5ab24..428c3c549 100644 --- a/server/levels/components/level_component_handler.coffee +++ b/server/handlers/level_component_handler.coffee @@ -1,10 +1,10 @@ -LevelComponent = require './../../models/LevelComponent' -Handler = require '../../commons/Handler' +LevelComponent = require './../models/LevelComponent' +Handler = require '../commons/Handler' mongoose = require 'mongoose' LevelComponentHandler = class LevelComponentHandler extends Handler modelClass: LevelComponent - jsonSchema: require '../../../app/schemas/models/level_component' + jsonSchema: require '../../app/schemas/models/level_component' editableProperties: [ 'system' 'description' diff --git a/server/levels/feedbacks/level_feedback_handler.coffee b/server/handlers/level_feedback_handler.coffee similarity index 68% rename from server/levels/feedbacks/level_feedback_handler.coffee rename to server/handlers/level_feedback_handler.coffee index 279e3e4ac..4eb8d1f68 100644 --- a/server/levels/feedbacks/level_feedback_handler.coffee +++ b/server/handlers/level_feedback_handler.coffee @@ -1,10 +1,10 @@ -LevelFeedback = require './../../models/LevelFeedback' -Handler = require '../../commons/Handler' +LevelFeedback = require './../models/LevelFeedback' +Handler = require '../commons/Handler' class LevelFeedbackHandler extends Handler modelClass: LevelFeedback editableProperties: ['rating', 'review', 'level', 'levelID', 'levelName'] - jsonSchema: require '../../../app/schemas/models/level_feedback' + jsonSchema: require '../../app/schemas/models/level_feedback' makeNewInstance: (req) -> feedback = super(req) diff --git a/server/levels/level_handler.coffee b/server/handlers/level_handler.coffee similarity index 99% rename from server/levels/level_handler.coffee rename to server/handlers/level_handler.coffee index c84413ebd..5fd573dd1 100644 --- a/server/levels/level_handler.coffee +++ b/server/handlers/level_handler.coffee @@ -1,7 +1,7 @@ Level = require './../models/Level' Session = require './../models/LevelSession' User = require '../models/User' -SessionHandler = require './sessions/level_session_handler' +SessionHandler = require './level_session_handler' Feedback = require './../models/LevelFeedback' Handler = require '../commons/Handler' mongoose = require 'mongoose' diff --git a/server/levels/sessions/level_session_handler.coffee b/server/handlers/level_session_handler.coffee similarity index 96% rename from server/levels/sessions/level_session_handler.coffee rename to server/handlers/level_session_handler.coffee index 2a48d2da8..f0ee67219 100644 --- a/server/levels/sessions/level_session_handler.coffee +++ b/server/handlers/level_session_handler.coffee @@ -1,5 +1,5 @@ -LevelSession = require './../../models/LevelSession' -Handler = require '../../commons/Handler' +LevelSession = require './../models/LevelSession' +Handler = require '../commons/Handler' log = require 'winston' TIMEOUT = 1000 * 30 # no activity for 30 seconds means it's not active diff --git a/server/levels/systems/level_system_handler.coffee b/server/handlers/level_system_handler.coffee similarity index 81% rename from server/levels/systems/level_system_handler.coffee rename to server/handlers/level_system_handler.coffee index ec825d7d8..b915d9dd7 100644 --- a/server/levels/systems/level_system_handler.coffee +++ b/server/handlers/level_system_handler.coffee @@ -1,5 +1,5 @@ -LevelSystem = require './../../models/LevelSystem' -Handler = require '../../commons/Handler' +LevelSystem = require './../models/LevelSystem' +Handler = require '../commons/Handler' LevelSystemHandler = class LevelSystemHandler extends Handler modelClass: LevelSystem @@ -13,7 +13,7 @@ LevelSystemHandler = class LevelSystemHandler extends Handler 'configSchema' ] postEditableProperties: ['name'] - jsonSchema: require '../../../app/schemas/models/level_system' + jsonSchema: require '../../app/schemas/models/level_system' getEditableProperties: (req, document) -> props = super(req, document) diff --git a/server/mail/sent/mail_sent_handler.coffee b/server/handlers/mail_sent_handler.coffee similarity index 57% rename from server/mail/sent/mail_sent_handler.coffee rename to server/handlers/mail_sent_handler.coffee index 63d6369ff..df10fc86b 100644 --- a/server/mail/sent/mail_sent_handler.coffee +++ b/server/handlers/mail_sent_handler.coffee @@ -1,10 +1,10 @@ -MailSent = require './../../models/MailSent' -Handler = require '../../commons/Handler' +MailSent = require './../models/MailSent' +Handler = require '../commons/Handler' class MailSentHandler extends Handler modelClass: MailSent editableProperties: ['mailTask','user','sent'] - jsonSchema: require '../../../app/schemas/models/mail_sent' + jsonSchema: require '../../app/schemas/models/mail_sent' hasAccess: (req) -> req.user?.isAdmin() diff --git a/server/patches/patch_handler.coffee b/server/handlers/patch_handler.coffee similarity index 100% rename from server/patches/patch_handler.coffee rename to server/handlers/patch_handler.coffee diff --git a/server/payments/payment_handler.coffee b/server/handlers/payment_handler.coffee similarity index 100% rename from server/payments/payment_handler.coffee rename to server/handlers/payment_handler.coffee diff --git a/server/polls/poll_handler.coffee b/server/handlers/poll_handler.coffee similarity index 100% rename from server/polls/poll_handler.coffee rename to server/handlers/poll_handler.coffee diff --git a/server/prepaids/prepaid_handler.coffee b/server/handlers/prepaid_handler.coffee similarity index 100% rename from server/prepaids/prepaid_handler.coffee rename to server/handlers/prepaid_handler.coffee diff --git a/server/purchases/purchase_handler.coffee b/server/handlers/purchase_handler.coffee similarity index 100% rename from server/purchases/purchase_handler.coffee rename to server/handlers/purchase_handler.coffee diff --git a/server/payments/subscription_handler.coffee b/server/handlers/subscription_handler.coffee similarity index 100% rename from server/payments/subscription_handler.coffee rename to server/handlers/subscription_handler.coffee diff --git a/server/levels/thangs/thang_type_handler.coffee b/server/handlers/thang_type_handler.coffee similarity index 95% rename from server/levels/thangs/thang_type_handler.coffee rename to server/handlers/thang_type_handler.coffee index 84d42bbe3..f2db7060f 100644 --- a/server/levels/thangs/thang_type_handler.coffee +++ b/server/handlers/thang_type_handler.coffee @@ -1,9 +1,9 @@ -ThangType = require './../../models/ThangType' -Handler = require '../../commons/Handler' +ThangType = require './../models/ThangType' +Handler = require '../commons/Handler' ThangTypeHandler = class ThangTypeHandler extends Handler modelClass: ThangType - jsonSchema: require '../../../app/schemas/models/thang_type' + jsonSchema: require '../../app/schemas/models/thang_type' editableProperties: [ 'name' 'raw' diff --git a/server/user_code_problems/user_code_problem_handler.coffee b/server/handlers/user_code_problem_handler.coffee similarity index 100% rename from server/user_code_problems/user_code_problem_handler.coffee rename to server/handlers/user_code_problem_handler.coffee diff --git a/server/users/user_handler.coffee b/server/handlers/user_handler.coffee similarity index 99% rename from server/users/user_handler.coffee rename to server/handlers/user_handler.coffee index 220df41ea..86ea5eadc 100644 --- a/server/users/user_handler.coffee +++ b/server/handlers/user_handler.coffee @@ -13,12 +13,12 @@ AnalyticsLogEvent = require '../models/AnalyticsLogEvent' Clan = require '../models/Clan' CourseInstance = require '../models/CourseInstance' LevelSession = require '../models/LevelSession' -LevelSessionHandler = require '../levels/sessions/level_session_handler' +LevelSessionHandler = require './level_session_handler' Payment = require '../models/Payment' -SubscriptionHandler = require '../payments/subscription_handler' -DiscountHandler = require '../payments/discount_handler' +SubscriptionHandler = require './subscription_handler' +DiscountHandler = require './discount_handler' EarnedAchievement = require '../models/EarnedAchievement' -UserRemark = require './remarks/UserRemark' +UserRemark = require './../models/UserRemark' {findStripeSubscription} = require '../lib/utils' {isID} = require '../lib/utils' slack = require '../slack' diff --git a/server/polls/user_polls_record_handler.coffee b/server/handlers/user_polls_record_handler.coffee similarity index 100% rename from server/polls/user_polls_record_handler.coffee rename to server/handlers/user_polls_record_handler.coffee diff --git a/server/users/remarks/user_remark_handler.coffee b/server/handlers/user_remark_handler.coffee similarity index 62% rename from server/users/remarks/user_remark_handler.coffee rename to server/handlers/user_remark_handler.coffee index 9cc7ff90b..6d103ee92 100644 --- a/server/users/remarks/user_remark_handler.coffee +++ b/server/handlers/user_remark_handler.coffee @@ -1,10 +1,10 @@ -UserRemark = require './UserRemark' -Handler = require '../../commons/Handler' +UserRemark = require './../models/UserRemark' +Handler = require '../commons/Handler' class UserRemarkHandler extends Handler modelClass: UserRemark editableProperties: ['user', 'contact', 'history', 'tasks', 'userName', 'contactName'] - jsonSchema: require '../../../app/schemas/models/user_remark' + jsonSchema: require '../../app/schemas/models/user_remark' hasAccess: (req) -> req.user?.isAdmin() diff --git a/server/lib/stripe_utils.coffee b/server/lib/stripe_utils.coffee index 03a00026f..457a01e6b 100644 --- a/server/lib/stripe_utils.coffee +++ b/server/lib/stripe_utils.coffee @@ -1,6 +1,6 @@ log = require 'winston' Payment = require '../models/Payment' -PaymentHandler = require '../payments/payment_handler' +PaymentHandler = require '../handlers/payment_handler' module.exports = logError: (user, msg) -> diff --git a/server/users/remarks/UserRemark.coffee b/server/models/UserRemark.coffee similarity index 72% rename from server/users/remarks/UserRemark.coffee rename to server/models/UserRemark.coffee index 15eb63a2b..52166a827 100644 --- a/server/users/remarks/UserRemark.coffee +++ b/server/models/UserRemark.coffee @@ -1,6 +1,6 @@ mongoose = require 'mongoose' -plugins = require '../../plugins/plugins' -jsonschema = require '../../../app/schemas/models/user_remark' +plugins = require '../plugins/plugins' +jsonschema = require '../../app/schemas/models/user_remark' UserRemarkSchema = new mongoose.Schema({ created: diff --git a/server/routes/auth.coffee b/server/routes/auth.coffee index 53d052928..d943218b9 100644 --- a/server/routes/auth.coffee +++ b/server/routes/auth.coffee @@ -1,7 +1,7 @@ authentication = require 'passport' LocalStrategy = require('passport-local').Strategy User = require '../models/User' -UserHandler = require '../users/user_handler' +UserHandler = require '../handlers/user_handler' LevelSession = require '../models/LevelSession' config = require '../../server_config' errors = require '../commons/errors' diff --git a/server/routes/mail.coffee b/server/routes/mail.coffee index fe2edbdbc..20abb99b9 100644 --- a/server/routes/mail.coffee +++ b/server/routes/mail.coffee @@ -1,6 +1,6 @@ mail = require '../commons/mail' MailSent = require '../models/MailSent' -UserRemark = require '../users/remarks/UserRemark' +UserRemark = require '../models/UserRemark' User = require '../models/User' async = require 'async' errors = require '../commons/errors' diff --git a/server_setup.coffee b/server_setup.coffee index 9d2a4164d..6d84fd7e4 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -10,12 +10,12 @@ geoip = require 'geoip-lite' database = require './server/commons/database' perfmon = require './server/commons/perfmon' baseRoute = require './server/routes/base' -user = require './server/users/user_handler' +user = require './server/handlers/user_handler' logging = require './server/commons/logging' config = require './server_config' auth = require './server/routes/auth' routes = require './server/routes' -UserHandler = require './server/users/user_handler' +UserHandler = require './server/handlers/user_handler' slack = require './server/slack' Mandate = require './server/models/Mandate' global.tv4 = require 'tv4' # required for TreemaUtils to work diff --git a/spec/server/functional/achievement.spec.coffee b/spec/server/functional/achievement.spec.coffee index 31523ed78..bd9cfef6e 100644 --- a/spec/server/functional/achievement.spec.coffee +++ b/spec/server/functional/achievement.spec.coffee @@ -223,7 +223,7 @@ describe 'Achieving Achievements', -> describe 'Recalculate Achievements', -> - EarnedAchievementHandler = require '../../../server/achievements/earned_achievement_handler' + EarnedAchievementHandler = require '../../../server/handlers/earned_achievement_handler' it 'remove earned achievements', (done) -> f = -> diff --git a/spec/server/functional/patch.spec.coffee b/spec/server/functional/patch.spec.coffee index a5516cefd..e9b30a619 100644 --- a/spec/server/functional/patch.spec.coffee +++ b/spec/server/functional/patch.spec.coffee @@ -6,7 +6,7 @@ request = require '../request' describe '/db/patch', -> async = require 'async' - UserHandler = require '../../../server/users/user_handler' + UserHandler = require '../../../server/handlers/user_handler' it 'clears the db first', (done) -> clearModels [User, Article, Patch], (err) -> diff --git a/spec/server/functional/user.spec.coffee b/spec/server/functional/user.spec.coffee index e77832708..02166cdfe 100644 --- a/spec/server/functional/user.spec.coffee +++ b/spec/server/functional/user.spec.coffee @@ -371,7 +371,7 @@ describe 'Statistics', -> LevelComponent = require '../../../server/models/LevelComponent' ThangType = require '../../../server/models/ThangType' User = require '../../../server/models/User' - UserHandler = require '../../../server/users/user_handler' + UserHandler = require '../../../server/handlers/user_handler' it 'keeps track of games completed', (done) -> session = new LevelSession