Repository: fossasia/open-event-server

Issue:
event_sub_topics is not initialized
In order to do the migration reliably we need event_sub_topics to be initialized just like event_topics are, what is important though is that it contains at least these values:
Comedy
City/Town
Dating
Volleyball
Yoga
Other
Avatar
Robotics
Logo
Food
Cultural
Craft
High Tech
Pop
Science
Medical
Education
Career
Baby
Startups &amp; Small Business
LGBT
Gaming
Easter
Top 40
EDM / Electronic
Educators
Social Media
Design
Auto
R&B
Medicine
Mobile
Anime/Comics
Mysticism and Occult
Classical
Air
Environment
Home & Garden
Beer
Fine Art
Reunion
Finance
Orchestra
Biotech
Non-partisan
Anime


Discussion:
Each event sub topic has a relation with event topic so please update the
above list alongwith it's event topic name.

On Thu, 9 Aug 2018 10:12 am Kreijstal, <notifications@github.com> wrote:

> In order to do the migration reliably we need event_sub_topics to be
> initialized just like event_topics are, what is important though is that it
> contains at least these values:
> Comedy
> City/Town
> Dating
> Volleyball
> Yoga
> Other
> Avatar
> Robotics
> Logo
> Food
> Cultural
> Craft
> High Tech
> Pop
> Science
> Medical
> Education
> Career
> Baby
> Startups & Small Business
> LGBT
> Gaming
> Easter
> Top 40
> EDM / Electronic
> Educators
> Social Media
> Design
> Auto
> R&B
> Medicine
> Mobile
> Anime/Comics
> Mysticism and Occult
> Classical
> Air
> Environment
> Home & Garden
> Beer
> Fine Art
> Reunion
> Finance
> Orchestra
> Biotech
> Non-partisan
> Anime
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/fossasia/open-event-server/issues/5315>, or mute the
> thread
> <https://github.com/notifications/unsubscribe-auth/AV37-l5YLDJp1_43oqXnJtpextyZ-ZVQks5uO73EgaJpZM4V1CLi>
> .
>

|           Sub_topic           |            Topic            |
|-------------------------------|-----------------------------|
| Comedy                        | Film, Media & Entertainment |
| Gaming                        | Film, Media & Entertainment |
| Anime                         | Film, Media & Entertainment |
| City/Town                     | Community & Culture         |
| Other                         | Community & Culture         |
| LGBT                          | Community & Culture         |
| Dating                        | Home & Lifestyle            |
| Home & Garden                 | Home & Lifestyle            |
| Volleyball                    | Sports & Fitness            |
| Other                         | Sports & Fitness            |
| Yoga                          | Health & Wellness           |
| Medical                       | Health & Wellness           |
| Other                         | Food & Drink                |
| Food                          | Food & Drink                |
| Beer                          | Food & Drink                |
| Avatar                        | Other                       |
| Logo                          | Other                       |
| Robotics                      | Science & Technology        |
| Other                         | Science & Technology        |
| High Tech                     | Science & Technology        |
| Science                       | Science & Technology        |
| Social Media                  | Science & Technology        |
| Medicine                      | Science & Technology        |
| Mobile                        | Science & Technology        |
| Biotech                       | Science & Technology        |
| Cultural                      | Music                       |
| Pop                           | Music                       |
| Top 40                        | Music                       |
| EDM / Electronic              | Music                       |
| R&B                           | Music                       |
| Other                         | Music                       |
| Classical                     | Music                       |
| Craft                         | Performing & Visual Arts    |
| Comedy                        | Performing & Visual Arts    |
| Fine Art                      | Performing & Visual Arts    |
| Orchestra                     | Performing & Visual Arts    |
| Education                     | Family & Education          |
| Baby                          | Family & Education          |
| Reunion                       | Family & Education          |
| Career                        | Business & Professional     |
| Startups &amp; Small Business | Business & Professional     |
| Educators                     | Business & Professional     |
| Design                        | Business & Professional     |
| Finance                       | Business & Professional     |
| Education                     | Charity & Causes            |
| Other                         | Charity & Causes            |
| Environment                   | Charity & Causes            |
| Other                         | Hobbies & Special Interest  |
| Anime/Comics                  | Hobbies & Special Interest  |
| Easter                        | Seasonal & Holiday          |
| Other                         | Seasonal & Holiday          |
| Auto                          | Auto, Boat & Air            |
| Air                           | Auto, Boat & Air            |
| Mysticism and Occult          | Religion & Spirituality     |
| Non-partisan                  | Government & Politics       |


@bhaveshAn there we go, [here](https://pastebin.com/0zPENBCA) is a json in case you need to parse the data

Resolving patch:
diff --git a/populate_db.py b/populate_db.py
--- a/populate_db.py
+++ b/populate_db.py
@@ -31,6 +31,9 @@
 # EventTopic
 from app.models.event_topic import EventTopic
 
+# EventSubTopic
+from app.models.event_sub_topic import EventSubTopic
+
 # EventType
 from app.models.event_type import EventType
 
@@ -141,6 +144,33 @@ def create_event_topics():
         get_or_create(EventTopic, name=topic)
 
 
+def create_event_sub_topics():
+    event_sub_topic = {
+     "Film, Media & Entertainment": ["Comedy", "Gaming", "Anime"],
+     "Community & Culture": ["City/Town", "Other", "LGBT"],
+     "Home & Lifestyle": ["Dating", "Home & Garden"],
+     "Sports & Fitness": ["Volleyball", "Other"],
+     "Health & Wellness": ["Yoga", "Medical"],
+     "Food & Drink": ["Other", "Food", "Beer"],
+     "Other": ["Avatar", "Logo"],
+     "Science & Technology": ["Robotics", "Other", "High Tech", "Science", "Social Media", "Medicine", "Mobile", "Biotech"],
+     "Music": ["Cultural", "Pop", "Top 40", "EDM / Electronic", "R&B", "Other", "Classical"],
+     "Performing & Visual Arts": ["Craft", "Comedy", "Fine Art", "Orchestra"],
+     "Family & Education": ["Education", "Baby", "Reunion"],
+     "Business & Professional": ["Career", "Startups &amp; Small Business", "Educators", "Design", "Finance"],
+     "Charity & Causes": ["Education", "Other", "Environment"],
+     "Hobbies & Special Interest": ["Other", "Anime/Comics"],
+     "Seasonal & Holiday": ["Easter", "Other"],
+     "Auto, Boat & Air": ["Auto", "Air"],
+     "Religion & Spirituality": ["Mysticism and Occult"],
+     "Government & Politics": ["Non-partisan"]
+    }
+    eventopics=db.session.query(EventTopic).all()
+    for keysub_topic in event_sub_topic:
+        for subtopic in event_sub_topic[keysub_topic]:
+            get_or_create(EventSubTopic, name=subtopic, event_topic_id=next(x for x in eventopics if x.name==keysub_topic).id)
+
+
 def create_event_types():
     event_type = ['Camp, Treat & Retreat', 'Dinner or Gala',
                   'Other', 'Concert or Performance', 'Conference',
@@ -168,7 +198,6 @@ def create_permissions():
     mod = Role.query.get(4)
     attend = Role.query.get(5)
     regist = Role.query.get(6)
-
     track = Service.query.get(1)
     session = Service.query.get(2)
     speaker = Service.query.get(3)
@@ -292,6 +321,8 @@ def populate():
     create_speaker_image_sizes()
     print('Creating Event Topics...')
     create_event_topics()
+    print('Creating Event SubTopics...')
+    create_event_sub_topics()
     print('Creating Event Types...')
     create_event_types()
     print('Creating Event Locations...')
@@ -315,6 +346,7 @@ def populate_without_print():
     create_event_image_sizes()
     create_speaker_image_sizes()
     create_event_topics()
+    create_event_sub_topics()
     create_event_types()
     create_event_locations()
     create_admin_message_settings()


Test patch: