Event.js 5.2 KB

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