Event.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import { User } from 'src/models/User.js'
  2. import { Unit } from 'src/models/Unit.js'
  3. import { Model, Collection } from 'js-abstract-model'
  4. class Event extends Model {
  5. constructor (data) {
  6. super(data, [
  7. { key: 'id' },
  8. { key: 'creator' },
  9. {
  10. key: 'creator_info',
  11. relatedModel: User
  12. },
  13. { key: 'thumbnail' },
  14. { key: 'title' },
  15. { key: 'holding_type' },
  16. { key: 'category' },
  17. { key: 'item_type' },
  18. { key: 'audience_gender_type' },
  19. { key: 'holding_year' },
  20. { key: 'holding_month' },
  21. { key: 'sessions_frequency' },
  22. { key: 'professor' },
  23. { key: 'specification' },
  24. { key: 'bulletin' },
  25. { key: 'current_user_register_info' },
  26. {
  27. key: 'professor_info',
  28. relatedModel: User
  29. },
  30. {
  31. key: 'tests',
  32. default: []
  33. },
  34. { key: 'unit' },
  35. {
  36. key: 'unit_info',
  37. relatedModel: Unit
  38. },
  39. { key: 'audience_role' },
  40. { key: 'price' },
  41. { key: 'codes' },
  42. { key: 'capacity' },
  43. { key: 'used_capacity' },
  44. { key: 'allowed_absence_count' },
  45. { key: 'effective_absence_coefficient' },
  46. { key: 'mandatory_assignment_count' },
  47. { key: 'minimum_passing_mark' },
  48. { key: 'minimum_conditional_passing_mark' },
  49. { key: 'minimum_clean_passing_mark' },
  50. { key: 'special_passing_mark' },
  51. { key: 'live_streaming_url' },
  52. { key: 'classroom_address' },
  53. { key: 'beginning_enrollment_period' },
  54. { key: 'ending_enrollment_period' },
  55. { key: 'beginning_registration_period' },
  56. { key: 'ending_registration_period' },
  57. { key: 'allow_dropping_on_registration_period' },
  58. { key: 'registration_period_refund_percent' },
  59. { key: 'beginning_drop_add_period' },
  60. { key: 'ending_drop_add_period' },
  61. { key: 'allow_adding_on_drop_add_period' },
  62. { key: 'allow_dropping_on_drop_add_period' },
  63. { key: 'drop_add_period_refund_percent' },
  64. { key: 'is_enabled_enrolment' },
  65. { key: 'is_enabled_adding' },
  66. { key: 'is_enabled_viewing' },
  67. { key: 'is_enabled_dropping' },
  68. { key: 'rules' },
  69. { key: 'description' },
  70. { key: 'is_current_user_registered' },
  71. { key: 'publish_time' },
  72. { key: 'creation_time' },
  73. { key: 'last_modification_time' },
  74. { key: 'is_active' },
  75. { key: 'is_deleted' },
  76. { key: 'status' }
  77. ], {
  78. status: {
  79. infoKey: 'status_info',
  80. enumListKey: 'statusEnums',
  81. enums: [
  82. { label: 'منتشر نشده', value: 'NOT_PUBLISHED_YET', showInUserFilters: false },
  83. { label: 'قبل از مرحله پیش ثبت نام', value: 'BEFORE_ENROLLMENT_PERIOD', showInUserFilters: false },
  84. { label: 'مرحله پیش ثبت نام', value: 'IN_ENROLLMENT_PERIOD', showInUserFilters: true },
  85. { label: 'قبل از مرحله ثبت نام', value: 'BEFORE_REGISTRATION_PERIOD', showInUserFilters: false },
  86. { label: 'مرحله ثبت نام', value: 'IN_REGISTRATION_PERIOD', showInUserFilters: true },
  87. { label: 'قبل از مرحله حذف و اضافه', value: 'BEFORE_DROP_ADD_PERIOD', showInUserFilters: false },
  88. { label: 'مرحله حذف و اضافه', value: 'IN_DROP_ADD_PERIOD', showInUserFilters: true },
  89. { label: 'جاری', value: 'ONGOING', showInUserFilters: true },
  90. { label: 'پایان یافته', value: 'FINISHED', showInUserFilters: true }
  91. ]
  92. },
  93. holding_type: {
  94. infoKey: 'holding_type_info',
  95. enumListKey: 'holding_typeEnums',
  96. enums: [
  97. { label: 'برخط(آنلاین)', value: 'ONLINE' },
  98. { label: 'برون خط(آفلاین)', value: 'OFFLINE' },
  99. { label: 'حضوری', value: 'FACE_TO_FACE' }
  100. ]
  101. },
  102. category: {
  103. infoKey: 'category_info',
  104. enumListKey: 'categoryEnums',
  105. enums: [
  106. { label: 'عمومی', value: 'OMOUMI' },
  107. { label: 'هیئت', value: 'HEIAT' },
  108. { label: 'ارزاق', value: 'ARZAGH' },
  109. { label: 'اردو', value: 'ORDOO' }
  110. ]
  111. },
  112. item_type: {
  113. infoKey: 'item_type_info',
  114. enumListKey: 'item_typeEnums',
  115. enums: [
  116. { label: 'دوره آموزشی', value: 'CLASSROOM' },
  117. { label: 'حلقه مباحثاتی', value: 'DISCUSSION_CIRCLE' }
  118. ]
  119. },
  120. audience_gender_type: {
  121. infoKey: 'audience_gender_type_info',
  122. enumListKey: 'audience_gender_typeEnums',
  123. enums: [
  124. { label: 'آقایان', value: 'MALE' },
  125. { label: 'خانم ها', value: 'FEMALE' },
  126. { label: 'خانم ها و آقایان', value: 'FEMALE_MALE' }
  127. ]
  128. }
  129. })
  130. if (!this.thumbnail) {
  131. this.thumbnail = '/assets/images/web/sample-class-thumbnail.jpg'
  132. }
  133. }
  134. getUserRegisterInfoLabel (status) {
  135. const enums = {
  136. REGISTERED: 'ثبت نام شده',
  137. ENROLLED: 'پیش ثبت نام شده',
  138. DROPPED_BY_ITSELF: 'حذف شده توسط اندیشه جو',
  139. DROPPED_BY_ADMIN: 'حذف شده توسط ادمین'
  140. }
  141. const target = status || this.current_user_register_info?.status
  142. return enums[target] || null
  143. }
  144. }
  145. class EventList extends Collection {
  146. model () {
  147. return Event
  148. }
  149. }
  150. export { Event, EventList }