Repository: fossasia/open-event-server

Issue:
Populate db for permissions of Attendee and Registrar
**Describe the bug**
<!-- A clear and concise description of what the bug is. -->
Database is not having permissions of Attendee and Registrar for events different services.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->

Populating db for Attendee and Registrar role required. in permissions.
**Stacktrace**
<!-- If applicable, add stacktrace to help explain your problem. -->

**Additional details (please complete the following information):**
 - OS: UBUNTU 16.04
 - Python Version : Python 3.5.2
 - `HEAD` Commit hash [e.g. `4629c62`]

**Additional context**
<!-- Add any other context about the problem here. -->

**Wanna work on this issue**


Discussion:

Resolving patch:
diff --git a/populate_db.py b/populate_db.py
--- a/populate_db.py
+++ b/populate_db.py
@@ -67,6 +67,8 @@ def create_permissions():
     coorgr = Role.query.get(2)
     track_orgr = Role.query.get(3)
     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)
@@ -76,32 +78,17 @@ def create_permissions():
 
     # For ORGANIZER
     # All four permissions set to True
-    get_or_create(Permission, role=orgr, service=track)
-    get_or_create(Permission, role=orgr, service=session)
-    get_or_create(Permission, role=orgr, service=speaker)
-    get_or_create(Permission, role=orgr, service=sponsor)
-    get_or_create(Permission, role=orgr, service=microlocation)
+    services = [track, session, speaker, sponsor, microlocation]
+    roles = [attend, regist]
+    for service in services:
+        perm, _ = get_or_create(Permission, role=orgr, service=service)
+        db.session.add(perm)
 
     # For COORGANIZER
-    perm, _ = get_or_create(Permission, role=coorgr, service=track)
-    perm.can_create, perm.can_delete = False, False
-    db.session.add(perm)
-
-    perm, _ = get_or_create(Permission, role=coorgr, service=session)
-    perm.can_create, perm.can_delete = False, False
-    db.session.add(perm)
-
-    perm, _ = get_or_create(Permission, role=coorgr, service=speaker)
-    perm.can_create, perm.can_delete = False, False
-    db.session.add(perm)
-
-    perm, _ = get_or_create(Permission, role=coorgr, service=sponsor)
-    perm.can_create, perm.can_delete = False, False
-    db.session.add(perm)
-
-    perm, _ = get_or_create(Permission, role=coorgr, service=microlocation)
-    perm.can_create, perm.can_delete = False, False
-    db.session.add(perm)
+    for service in services:
+        perm, _ = get_or_create(Permission, role=coorgr, service=service)
+        perm.can_create, perm.can_delete = False, False
+        db.session.add(perm)
 
     # For TRACK_ORGANIZER
     perm, _ = get_or_create(Permission, role=track_orgr, service=track)
@@ -112,6 +99,15 @@ def create_permissions():
     perm.can_create, perm.can_update, perm.can_delete = False, False, False
     db.session.add(perm)
 
+    # For ATTENDEE and REGISTRAR
+    services = [track, session, speaker, sponsor, microlocation]
+    roles = [attend, regist]
+    for role in roles:
+        for service in services:
+            perm, _ = get_or_create(Permission, role=role, service=service)
+            perm.can_create, perm.can_update, perm.can_delete = False, False, False
+            db.session.add(perm)
+
 
 def create_custom_sys_roles():
     role, _ = get_or_create(CustomSysRole, name='Sales Admin')


Test patch: