We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Update populate_db.py to add Paypal sandbox keys.
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Update populate_db.py to add Paypal sandbox keys.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `populate_db.py`
Content:
```
1 from app import current_app
2 from app.models import db
3 from app.api.helpers.db import get_or_create  # , save_to_db
4 from envparse import env
5 
6 # Admin message settings
7 from app.api.helpers.system_mails import MAILS
8 from app.models.message_setting import MessageSettings
9 
10 # Event Role-Service Permissions
11 from app.models.role import Role
12 from app.models.service import Service
13 from app.models.permission import Permission
14 
15 from app.models.track import Track
16 from app.models.session import Session
17 from app.models.speaker import Speaker
18 from app.models.sponsor import Sponsor
19 from app.models.microlocation import Microlocation
20 
21 from app.models.user import ORGANIZER, COORGANIZER, TRACK_ORGANIZER, MODERATOR, ATTENDEE, REGISTRAR
22 
23 # Admin Panel Permissions
24 from app.models.panel_permission import PanelPermission
25 from app.models.custom_system_role import CustomSysRole
26 
27 from app.models.setting import Setting
28 from app.models.image_size import ImageSizes
29 from app.models.module import Module
30 
31 # EventTopic
32 from app.models.event_topic import EventTopic
33 
34 # EventType
35 from app.models.event_type import EventType
36 
37 # EventLocation
38 from app.models.event_location import EventLocation
39 
40 # User Permissions
41 from app.models.user_permission import UserPermission
42 SALES = 'sales'
43 
44 
45 def create_roles():
46     get_or_create(Role, name=ORGANIZER, title_name='Organizer')
47     get_or_create(Role, name=COORGANIZER, title_name='Co-organizer')
48     get_or_create(Role, name=TRACK_ORGANIZER, title_name='Track Organizer')
49     get_or_create(Role, name=MODERATOR, title_name='Moderator')
50     get_or_create(Role, name=ATTENDEE, title_name='Attendee')
51     get_or_create(Role, name=REGISTRAR, title_name='Registrar')
52 
53 
54 def create_services():
55     track = Track.get_service_name()
56     session = Session.get_service_name()
57     speaker = Speaker.get_service_name()
58     sponsor = Sponsor.get_service_name()
59     microlocation = Microlocation.get_service_name()
60 
61     get_or_create(Service, name=track)
62     get_or_create(Service, name=session)
63     get_or_create(Service, name=speaker)
64     get_or_create(Service, name=sponsor)
65     get_or_create(Service, name=microlocation)
66 
67 
68 def create_settings():
69     get_or_create(Setting, app_name='Open Event')
70 
71     if current_app.config['DEVELOPMENT']:
72         # get the stripe keys from the env file and save it in the settings.
73         env.read_envfile()
74         stripe_secret_key = env('STRIPE_SECRET_KEY', default=None)
75         stripe_publishable_key = env('STRIPE_PUBLISHABLE_KEY', default=None)
76         stripe_client_id = env('STRIPE_CLIENT_ID', default=None)
77         fb_client_id = env('FACEBOOK_CLIENT_ID', default=None)
78         fb_client_secret = env('FACEBOOK_CLIENT_SECRET', default=None)
79         google_client_id = env('GOOGLE_CLIENT_ID', default=None)
80         google_client_secret = env('GOOGLE_CLIENT_SECRET', default=None)
81         tw_consumer_key = env('TWITTER_CONSUMER_KEY', default=None)
82         tw_consumer_secret = env('TWITTER_CONSUMER_SECRET', default=None)
83         in_client_id = env('INSTAGRAM_CLIENT_ID', default=None)
84         in_client_secret = env('INSTAGRAM_CLIENT_SECRET', default=None)
85 
86         setting, _ = get_or_create(Setting, app_name='Open Event')
87         setting.stripe_client_id = stripe_client_id
88         setting.stripe_publishable_key = stripe_publishable_key
89         setting.stripe_secret_key = stripe_secret_key
90         setting.fb_client_id = fb_client_id
91         setting.fb_client_secret = fb_client_secret
92         setting.google_client_id = google_client_id
93         setting.google_client_secret = google_client_secret
94         setting.tw_consumer_key = tw_consumer_key
95         setting.tw_consumer_secret = tw_consumer_secret
96         setting.in_client_id = in_client_id
97         setting.in_client_secret = in_client_secret
98         db.session.add(setting)
99         db.session.commit()
100 
101 
102 def create_event_image_sizes():
103     get_or_create(
104         ImageSizes, type='event-image', full_width=1300,
105         full_height=500, full_aspect=True, full_quality=80,
106         icon_width=75, icon_height=30, icon_aspect=True,
107         icon_quality=80, thumbnail_width=500, thumbnail_height=200,
108         thumbnail_aspect=True, thumbnail_quality=80, logo_width=500,
109         logo_height=200
110     )
111 
112 
113 def create_speaker_image_sizes():
114     get_or_create(
115         ImageSizes, type='speaker-image', icon_size_width_height=35, icon_size_quality=80,
116         small_size_width_height=50, small_size_quality=80,
117         thumbnail_size_width_height=500, thumbnail_quality=80
118     )
119 
120 
121 def create_modules():
122     get_or_create(Module, donation_include=False)
123 
124 
125 def create_event_topics():
126     event_topic = ['Health & Wellness', 'Home & Lifestyle',
127                    'Charity & Causes', 'Other', 'Religion & Spirituality',
128                    'Community & Culture', 'Government & Politics',
129                    'Government & Politics', 'Auto, Boat & Air',
130                    'Travel & Outdoor', 'Hobbies & Special Interest',
131                    'Sports & Fitness', 'Business & Professional',
132                    'Music', 'Seasonal & Holiday',
133                    'Film, Media & Entertainment', 'Family & Education',
134                    'Science & Technology', 'Performing & Visual Arts',
135                    'Food & Drink', 'Family & Education']
136     for topic in event_topic:
137         get_or_create(EventTopic, name=topic)
138 
139 
140 def create_event_types():
141     event_type = ['Camp, Treat & Retreat', 'Dinner or Gala',
142                   'Other', 'Concert or Performance', 'Conference',
143                   'Seminar or Talk', 'Convention',
144                   'Festival or Fair', 'Tour',
145                   'Screening', 'Game or Competition',
146                   'Party or Social Gathering', 'Race or Endurance Event',
147                   'Meeting or Networking Event', 'Attraction',
148                   'Class, Training, or Workshop', 'Appearance or Signing',
149                   'Tournament', 'Rally']
150     for type_ in event_type:
151         get_or_create(EventType, name=type_)
152 
153 
154 def create_event_locations():
155     event_location = ['India', 'Singapore', 'Berlin', 'New York', 'Hong Kong']
156     for loc_ in event_location:
157         get_or_create(EventLocation, name=loc_)
158 
159 
160 def create_permissions():
161     orgr = Role.query.get(1)
162     coorgr = Role.query.get(2)
163     track_orgr = Role.query.get(3)
164     mod = Role.query.get(4)
165     attend = Role.query.get(5)
166     regist = Role.query.get(6)
167 
168     track = Service.query.get(1)
169     session = Service.query.get(2)
170     speaker = Service.query.get(3)
171     sponsor = Service.query.get(4)
172     microlocation = Service.query.get(5)
173 
174     # For ORGANIZER
175     # All four permissions set to True
176     services = [track, session, speaker, sponsor, microlocation]
177     roles = [attend, regist]
178     for service in services:
179         perm, _ = get_or_create(Permission, role=orgr, service=service)
180         db.session.add(perm)
181 
182     # For COORGANIZER
183     for service in services:
184         perm, _ = get_or_create(Permission, role=coorgr, service=service)
185         perm.can_create, perm.can_delete = False, False
186         db.session.add(perm)
187 
188     # For TRACK_ORGANIZER
189     for service in services:
190         perm, _ = get_or_create(Permission, role=track_orgr, service=service)
191         if not service == track:
192             perm.can_create, perm.can_update, perm.can_delete = False, False, False
193         db.session.add(perm)
194 
195     # For MODERATOR
196     for service in services:
197         perm, _ = get_or_create(Permission, role=mod, service=service)
198         perm.can_create, perm.can_update, perm.can_delete = False, False, False
199         db.session.add(perm)
200 
201     # For ATTENDEE and REGISTRAR
202     services = [track, session, speaker, sponsor, microlocation]
203     roles = [attend, regist]
204     for role in roles:
205         for service in services:
206             perm, _ = get_or_create(Permission, role=role, service=service)
207             perm.can_create, perm.can_update, perm.can_delete = False, False, False
208             db.session.add(perm)
209 
210 
211 def create_custom_sys_roles():
212     role, _ = get_or_create(CustomSysRole, name='Sales Admin')
213     db.session.add(role)
214     role, _ = get_or_create(CustomSysRole, name='Marketer')
215     db.session.add(role)
216 
217 
218 def create_panel_permissions():
219     sales_admin = CustomSysRole.query.filter_by(name='Sales Admin').first()
220     perm, _ = get_or_create(PanelPermission, panel_name=SALES, role=sales_admin)
221     db.session.add(perm)
222     marketer = CustomSysRole.query.filter_by(name='Marketer').first()
223     perm, _ = get_or_create(PanelPermission, panel_name=SALES, role=marketer)
224     db.session.add(perm)
225 
226 
227 def create_user_permissions():
228     # Publish Event
229     user_perm, _ = get_or_create(UserPermission, name='publish_event',
230                                  description='Publish event (make event live)')
231     user_perm.verified_user = True
232     db.session.add(user_perm)
233 
234     # Create Event
235     user_perm, _ = get_or_create(UserPermission, name='create_event',
236                                  description='Create event')
237     user_perm.verified_user, user_perm.unverified_user = True, False
238     db.session.add(user_perm)
239 
240 
241 def create_admin_message_settings():
242     default_mails = ["Next Event",
243                      "Session Schedule Change",
244                      "User email",
245                      "Invitation For Papers",
246                      "After Event",
247                      "Ticket(s) Purchased",
248                      "Session Accept or Reject",
249                      "Event Published",
250                      "Event Export Failed",
251                      "Event Exported",
252                      "Event Role Invitation",
253                      "New Session Proposal"]
254     for mail in MAILS:
255         if mail in default_mails:
256             get_or_create(MessageSettings, action=mail, mail_status=True,
257                           notification_status=True, user_control_status=True)
258         else:
259             get_or_create(
260                 MessageSettings, action=mail, mail_status=False,
261                 notification_status=False, user_control_status=False
262             )
263 
264 
265 def populate():
266     """
267     Create defined Roles, Services and Permissions.
268     """
269     print('Creating roles...')
270     create_roles()
271     print('Creating services...')
272     create_services()
273     print('Creating permissions...')
274     create_permissions()
275     print('Creating custom system roles...')
276     create_custom_sys_roles()
277     print('Creating admin panel permissions...')
278     create_panel_permissions()
279     print('Creating user permissions...')
280     create_user_permissions()
281     print('Creating settings...')
282     create_settings()
283     print('Creating modules...')
284     create_modules()
285     print('Creating event image size...')
286     create_event_image_sizes()
287     print('Creating speaker image size...')
288     create_speaker_image_sizes()
289     print('Creating Event Topics...')
290     create_event_topics()
291     print('Creating Event Types...')
292     create_event_types()
293     print('Creating Event Locations...')
294     create_event_locations()
295     print('Creating admin message settings...')
296     create_admin_message_settings()
297 
298 
299 def populate_without_print():
300     """
301     Create defined Roles, Services and Permissions.
302     """
303     create_roles()
304     create_services()
305     create_permissions()
306     create_custom_sys_roles()
307     create_panel_permissions()
308     create_user_permissions()
309     create_settings()
310     create_modules()
311     create_event_image_sizes()
312     create_speaker_image_sizes()
313     create_event_topics()
314     create_event_types()
315     create_event_locations()
316     create_admin_message_settings()
317 
318     db.session.commit()
319 
320 
321 if __name__ == '__main__':
322     with current_app.app_context():
323         populate()
324
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/populate_db.py b/populate_db.py
--- a/populate_db.py
+++ b/populate_db.py
@@ -74,6 +74,8 @@
         stripe_secret_key = env('STRIPE_SECRET_KEY', default=None)
         stripe_publishable_key = env('STRIPE_PUBLISHABLE_KEY', default=None)
         stripe_client_id = env('STRIPE_CLIENT_ID', default=None)
+        paypal_sandbox_client = env('PAYPAL_SANDBOX_CLIENT', default=None)
+        paypal_sandbox_secret = env('PAYPAL_SANDBOX_SECRET', default=None)
         fb_client_id = env('FACEBOOK_CLIENT_ID', default=None)
         fb_client_secret = env('FACEBOOK_CLIENT_SECRET', default=None)
         google_client_id = env('GOOGLE_CLIENT_ID', default=None)
@@ -87,6 +89,8 @@
         setting.stripe_client_id = stripe_client_id
         setting.stripe_publishable_key = stripe_publishable_key
         setting.stripe_secret_key = stripe_secret_key
+        setting.paypal_sandbox_client = paypal_sandbox_client
+        setting.paypal_sandbox_secret = paypal_sandbox_secret
         setting.fb_client_id = fb_client_id
         setting.fb_client_secret = fb_client_secret
         setting.google_client_id = google_client_id

{"golden_diff": "diff --git a/populate_db.py b/populate_db.py\n--- a/populate_db.py\n+++ b/populate_db.py\n@@ -74,6 +74,8 @@\n         stripe_secret_key = env('STRIPE_SECRET_KEY', default=None)\n         stripe_publishable_key = env('STRIPE_PUBLISHABLE_KEY', default=None)\n         stripe_client_id = env('STRIPE_CLIENT_ID', default=None)\n+        paypal_sandbox_client = env('PAYPAL_SANDBOX_CLIENT', default=None)\n+        paypal_sandbox_secret = env('PAYPAL_SANDBOX_SECRET', default=None)\n         fb_client_id = env('FACEBOOK_CLIENT_ID', default=None)\n         fb_client_secret = env('FACEBOOK_CLIENT_SECRET', default=None)\n         google_client_id = env('GOOGLE_CLIENT_ID', default=None)\n@@ -87,6 +89,8 @@\n         setting.stripe_client_id = stripe_client_id\n         setting.stripe_publishable_key = stripe_publishable_key\n         setting.stripe_secret_key = stripe_secret_key\n+        setting.paypal_sandbox_client = paypal_sandbox_client\n+        setting.paypal_sandbox_secret = paypal_sandbox_secret\n         setting.fb_client_id = fb_client_id\n         setting.fb_client_secret = fb_client_secret\n         setting.google_client_id = google_client_id\n", "issue": "Update populate_db.py to add Paypal sandbox keys.\n**Is your feature request related to a problem? Please describe.**\r\n<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->\r\nUpdate populate_db.py to add Paypal sandbox keys.\r\n\n", "before_files": [{"content": "from app import current_app\nfrom app.models import db\nfrom app.api.helpers.db import get_or_create  # , save_to_db\nfrom envparse import env\n\n# Admin message settings\nfrom app.api.helpers.system_mails import MAILS\nfrom app.models.message_setting import MessageSettings\n\n# Event Role-Service Permissions\nfrom app.models.role import Role\nfrom app.models.service import Service\nfrom app.models.permission import Permission\n\nfrom app.models.track import Track\nfrom app.models.session import Session\nfrom app.models.speaker import Speaker\nfrom app.models.sponsor import Sponsor\nfrom app.models.microlocation import Microlocation\n\nfrom app.models.user import ORGANIZER, COORGANIZER, TRACK_ORGANIZER, MODERATOR, ATTENDEE, REGISTRAR\n\n# Admin Panel Permissions\nfrom app.models.panel_permission import PanelPermission\nfrom app.models.custom_system_role import CustomSysRole\n\nfrom app.models.setting import Setting\nfrom app.models.image_size import ImageSizes\nfrom app.models.module import Module\n\n# EventTopic\nfrom app.models.event_topic import EventTopic\n\n# EventType\nfrom app.models.event_type import EventType\n\n# EventLocation\nfrom app.models.event_location import EventLocation\n\n# User Permissions\nfrom app.models.user_permission import UserPermission\nSALES = 'sales'\n\n\ndef create_roles():\n    get_or_create(Role, name=ORGANIZER, title_name='Organizer')\n    get_or_create(Role, name=COORGANIZER, title_name='Co-organizer')\n    get_or_create(Role, name=TRACK_ORGANIZER, title_name='Track Organizer')\n    get_or_create(Role, name=MODERATOR, title_name='Moderator')\n    get_or_create(Role, name=ATTENDEE, title_name='Attendee')\n    get_or_create(Role, name=REGISTRAR, title_name='Registrar')\n\n\ndef create_services():\n    track = Track.get_service_name()\n    session = Session.get_service_name()\n    speaker = Speaker.get_service_name()\n    sponsor = Sponsor.get_service_name()\n    microlocation = Microlocation.get_service_name()\n\n    get_or_create(Service, name=track)\n    get_or_create(Service, name=session)\n    get_or_create(Service, name=speaker)\n    get_or_create(Service, name=sponsor)\n    get_or_create(Service, name=microlocation)\n\n\ndef create_settings():\n    get_or_create(Setting, app_name='Open Event')\n\n    if current_app.config['DEVELOPMENT']:\n        # get the stripe keys from the env file and save it in the settings.\n        env.read_envfile()\n        stripe_secret_key = env('STRIPE_SECRET_KEY', default=None)\n        stripe_publishable_key = env('STRIPE_PUBLISHABLE_KEY', default=None)\n        stripe_client_id = env('STRIPE_CLIENT_ID', default=None)\n        fb_client_id = env('FACEBOOK_CLIENT_ID', default=None)\n        fb_client_secret = env('FACEBOOK_CLIENT_SECRET', default=None)\n        google_client_id = env('GOOGLE_CLIENT_ID', default=None)\n        google_client_secret = env('GOOGLE_CLIENT_SECRET', default=None)\n        tw_consumer_key = env('TWITTER_CONSUMER_KEY', default=None)\n        tw_consumer_secret = env('TWITTER_CONSUMER_SECRET', default=None)\n        in_client_id = env('INSTAGRAM_CLIENT_ID', default=None)\n        in_client_secret = env('INSTAGRAM_CLIENT_SECRET', default=None)\n\n        setting, _ = get_or_create(Setting, app_name='Open Event')\n        setting.stripe_client_id = stripe_client_id\n        setting.stripe_publishable_key = stripe_publishable_key\n        setting.stripe_secret_key = stripe_secret_key\n        setting.fb_client_id = fb_client_id\n        setting.fb_client_secret = fb_client_secret\n        setting.google_client_id = google_client_id\n        setting.google_client_secret = google_client_secret\n        setting.tw_consumer_key = tw_consumer_key\n        setting.tw_consumer_secret = tw_consumer_secret\n        setting.in_client_id = in_client_id\n        setting.in_client_secret = in_client_secret\n        db.session.add(setting)\n        db.session.commit()\n\n\ndef create_event_image_sizes():\n    get_or_create(\n        ImageSizes, type='event-image', full_width=1300,\n        full_height=500, full_aspect=True, full_quality=80,\n        icon_width=75, icon_height=30, icon_aspect=True,\n        icon_quality=80, thumbnail_width=500, thumbnail_height=200,\n        thumbnail_aspect=True, thumbnail_quality=80, logo_width=500,\n        logo_height=200\n    )\n\n\ndef create_speaker_image_sizes():\n    get_or_create(\n        ImageSizes, type='speaker-image', icon_size_width_height=35, icon_size_quality=80,\n        small_size_width_height=50, small_size_quality=80,\n        thumbnail_size_width_height=500, thumbnail_quality=80\n    )\n\n\ndef create_modules():\n    get_or_create(Module, donation_include=False)\n\n\ndef create_event_topics():\n    event_topic = ['Health & Wellness', 'Home & Lifestyle',\n                   'Charity & Causes', 'Other', 'Religion & Spirituality',\n                   'Community & Culture', 'Government & Politics',\n                   'Government & Politics', 'Auto, Boat & Air',\n                   'Travel & Outdoor', 'Hobbies & Special Interest',\n                   'Sports & Fitness', 'Business & Professional',\n                   'Music', 'Seasonal & Holiday',\n                   'Film, Media & Entertainment', 'Family & Education',\n                   'Science & Technology', 'Performing & Visual Arts',\n                   'Food & Drink', 'Family & Education']\n    for topic in event_topic:\n        get_or_create(EventTopic, name=topic)\n\n\ndef create_event_types():\n    event_type = ['Camp, Treat & Retreat', 'Dinner or Gala',\n                  'Other', 'Concert or Performance', 'Conference',\n                  'Seminar or Talk', 'Convention',\n                  'Festival or Fair', 'Tour',\n                  'Screening', 'Game or Competition',\n                  'Party or Social Gathering', 'Race or Endurance Event',\n                  'Meeting or Networking Event', 'Attraction',\n                  'Class, Training, or Workshop', 'Appearance or Signing',\n                  'Tournament', 'Rally']\n    for type_ in event_type:\n        get_or_create(EventType, name=type_)\n\n\ndef create_event_locations():\n    event_location = ['India', 'Singapore', 'Berlin', 'New York', 'Hong Kong']\n    for loc_ in event_location:\n        get_or_create(EventLocation, name=loc_)\n\n\ndef create_permissions():\n    orgr = Role.query.get(1)\n    coorgr = Role.query.get(2)\n    track_orgr = Role.query.get(3)\n    mod = Role.query.get(4)\n    attend = Role.query.get(5)\n    regist = Role.query.get(6)\n\n    track = Service.query.get(1)\n    session = Service.query.get(2)\n    speaker = Service.query.get(3)\n    sponsor = Service.query.get(4)\n    microlocation = Service.query.get(5)\n\n    # For ORGANIZER\n    # All four permissions set to True\n    services = [track, session, speaker, sponsor, microlocation]\n    roles = [attend, regist]\n    for service in services:\n        perm, _ = get_or_create(Permission, role=orgr, service=service)\n        db.session.add(perm)\n\n    # For COORGANIZER\n    for service in services:\n        perm, _ = get_or_create(Permission, role=coorgr, service=service)\n        perm.can_create, perm.can_delete = False, False\n        db.session.add(perm)\n\n    # For TRACK_ORGANIZER\n    for service in services:\n        perm, _ = get_or_create(Permission, role=track_orgr, service=service)\n        if not service == track:\n            perm.can_create, perm.can_update, perm.can_delete = False, False, False\n        db.session.add(perm)\n\n    # For MODERATOR\n    for service in services:\n        perm, _ = get_or_create(Permission, role=mod, service=service)\n        perm.can_create, perm.can_update, perm.can_delete = False, False, False\n        db.session.add(perm)\n\n    # For ATTENDEE and REGISTRAR\n    services = [track, session, speaker, sponsor, microlocation]\n    roles = [attend, regist]\n    for role in roles:\n        for service in services:\n            perm, _ = get_or_create(Permission, role=role, service=service)\n            perm.can_create, perm.can_update, perm.can_delete = False, False, False\n            db.session.add(perm)\n\n\ndef create_custom_sys_roles():\n    role, _ = get_or_create(CustomSysRole, name='Sales Admin')\n    db.session.add(role)\n    role, _ = get_or_create(CustomSysRole, name='Marketer')\n    db.session.add(role)\n\n\ndef create_panel_permissions():\n    sales_admin = CustomSysRole.query.filter_by(name='Sales Admin').first()\n    perm, _ = get_or_create(PanelPermission, panel_name=SALES, role=sales_admin)\n    db.session.add(perm)\n    marketer = CustomSysRole.query.filter_by(name='Marketer').first()\n    perm, _ = get_or_create(PanelPermission, panel_name=SALES, role=marketer)\n    db.session.add(perm)\n\n\ndef create_user_permissions():\n    # Publish Event\n    user_perm, _ = get_or_create(UserPermission, name='publish_event',\n                                 description='Publish event (make event live)')\n    user_perm.verified_user = True\n    db.session.add(user_perm)\n\n    # Create Event\n    user_perm, _ = get_or_create(UserPermission, name='create_event',\n                                 description='Create event')\n    user_perm.verified_user, user_perm.unverified_user = True, False\n    db.session.add(user_perm)\n\n\ndef create_admin_message_settings():\n    default_mails = [\"Next Event\",\n                     \"Session Schedule Change\",\n                     \"User email\",\n                     \"Invitation For Papers\",\n                     \"After Event\",\n                     \"Ticket(s) Purchased\",\n                     \"Session Accept or Reject\",\n                     \"Event Published\",\n                     \"Event Export Failed\",\n                     \"Event Exported\",\n                     \"Event Role Invitation\",\n                     \"New Session Proposal\"]\n    for mail in MAILS:\n        if mail in default_mails:\n            get_or_create(MessageSettings, action=mail, mail_status=True,\n                          notification_status=True, user_control_status=True)\n        else:\n            get_or_create(\n                MessageSettings, action=mail, mail_status=False,\n                notification_status=False, user_control_status=False\n            )\n\n\ndef populate():\n    \"\"\"\n    Create defined Roles, Services and Permissions.\n    \"\"\"\n    print('Creating roles...')\n    create_roles()\n    print('Creating services...')\n    create_services()\n    print('Creating permissions...')\n    create_permissions()\n    print('Creating custom system roles...')\n    create_custom_sys_roles()\n    print('Creating admin panel permissions...')\n    create_panel_permissions()\n    print('Creating user permissions...')\n    create_user_permissions()\n    print('Creating settings...')\n    create_settings()\n    print('Creating modules...')\n    create_modules()\n    print('Creating event image size...')\n    create_event_image_sizes()\n    print('Creating speaker image size...')\n    create_speaker_image_sizes()\n    print('Creating Event Topics...')\n    create_event_topics()\n    print('Creating Event Types...')\n    create_event_types()\n    print('Creating Event Locations...')\n    create_event_locations()\n    print('Creating admin message settings...')\n    create_admin_message_settings()\n\n\ndef populate_without_print():\n    \"\"\"\n    Create defined Roles, Services and Permissions.\n    \"\"\"\n    create_roles()\n    create_services()\n    create_permissions()\n    create_custom_sys_roles()\n    create_panel_permissions()\n    create_user_permissions()\n    create_settings()\n    create_modules()\n    create_event_image_sizes()\n    create_speaker_image_sizes()\n    create_event_topics()\n    create_event_types()\n    create_event_locations()\n    create_admin_message_settings()\n\n    db.session.commit()\n\n\nif __name__ == '__main__':\n    with current_app.app_context():\n        populate()\n", "path": "populate_db.py"}], "after_files": [{"content": "from app import current_app\nfrom app.models import db\nfrom app.api.helpers.db import get_or_create  # , save_to_db\nfrom envparse import env\n\n# Admin message settings\nfrom app.api.helpers.system_mails import MAILS\nfrom app.models.message_setting import MessageSettings\n\n# Event Role-Service Permissions\nfrom app.models.role import Role\nfrom app.models.service import Service\nfrom app.models.permission import Permission\n\nfrom app.models.track import Track\nfrom app.models.session import Session\nfrom app.models.speaker import Speaker\nfrom app.models.sponsor import Sponsor\nfrom app.models.microlocation import Microlocation\n\nfrom app.models.user import ORGANIZER, COORGANIZER, TRACK_ORGANIZER, MODERATOR, ATTENDEE, REGISTRAR\n\n# Admin Panel Permissions\nfrom app.models.panel_permission import PanelPermission\nfrom app.models.custom_system_role import CustomSysRole\n\nfrom app.models.setting import Setting\nfrom app.models.image_size import ImageSizes\nfrom app.models.module import Module\n\n# EventTopic\nfrom app.models.event_topic import EventTopic\n\n# EventType\nfrom app.models.event_type import EventType\n\n# EventLocation\nfrom app.models.event_location import EventLocation\n\n# User Permissions\nfrom app.models.user_permission import UserPermission\nSALES = 'sales'\n\n\ndef create_roles():\n    get_or_create(Role, name=ORGANIZER, title_name='Organizer')\n    get_or_create(Role, name=COORGANIZER, title_name='Co-organizer')\n    get_or_create(Role, name=TRACK_ORGANIZER, title_name='Track Organizer')\n    get_or_create(Role, name=MODERATOR, title_name='Moderator')\n    get_or_create(Role, name=ATTENDEE, title_name='Attendee')\n    get_or_create(Role, name=REGISTRAR, title_name='Registrar')\n\n\ndef create_services():\n    track = Track.get_service_name()\n    session = Session.get_service_name()\n    speaker = Speaker.get_service_name()\n    sponsor = Sponsor.get_service_name()\n    microlocation = Microlocation.get_service_name()\n\n    get_or_create(Service, name=track)\n    get_or_create(Service, name=session)\n    get_or_create(Service, name=speaker)\n    get_or_create(Service, name=sponsor)\n    get_or_create(Service, name=microlocation)\n\n\ndef create_settings():\n    get_or_create(Setting, app_name='Open Event')\n\n    if current_app.config['DEVELOPMENT']:\n        # get the stripe keys from the env file and save it in the settings.\n        env.read_envfile()\n        stripe_secret_key = env('STRIPE_SECRET_KEY', default=None)\n        stripe_publishable_key = env('STRIPE_PUBLISHABLE_KEY', default=None)\n        stripe_client_id = env('STRIPE_CLIENT_ID', default=None)\n        paypal_sandbox_client = env('PAYPAL_SANDBOX_CLIENT', default=None)\n        paypal_sandbox_secret = env('PAYPAL_SANDBOX_SECRET', default=None)\n        fb_client_id = env('FACEBOOK_CLIENT_ID', default=None)\n        fb_client_secret = env('FACEBOOK_CLIENT_SECRET', default=None)\n        google_client_id = env('GOOGLE_CLIENT_ID', default=None)\n        google_client_secret = env('GOOGLE_CLIENT_SECRET', default=None)\n        tw_consumer_key = env('TWITTER_CONSUMER_KEY', default=None)\n        tw_consumer_secret = env('TWITTER_CONSUMER_SECRET', default=None)\n        in_client_id = env('INSTAGRAM_CLIENT_ID', default=None)\n        in_client_secret = env('INSTAGRAM_CLIENT_SECRET', default=None)\n\n        setting, _ = get_or_create(Setting, app_name='Open Event')\n        setting.stripe_client_id = stripe_client_id\n        setting.stripe_publishable_key = stripe_publishable_key\n        setting.stripe_secret_key = stripe_secret_key\n        setting.paypal_sandbox_client = paypal_sandbox_client\n        setting.paypal_sandbox_secret = paypal_sandbox_secret\n        setting.fb_client_id = fb_client_id\n        setting.fb_client_secret = fb_client_secret\n        setting.google_client_id = google_client_id\n        setting.google_client_secret = google_client_secret\n        setting.tw_consumer_key = tw_consumer_key\n        setting.tw_consumer_secret = tw_consumer_secret\n        setting.in_client_id = in_client_id\n        setting.in_client_secret = in_client_secret\n        db.session.add(setting)\n        db.session.commit()\n\n\ndef create_event_image_sizes():\n    get_or_create(\n        ImageSizes, type='event-image', full_width=1300,\n        full_height=500, full_aspect=True, full_quality=80,\n        icon_width=75, icon_height=30, icon_aspect=True,\n        icon_quality=80, thumbnail_width=500, thumbnail_height=200,\n        thumbnail_aspect=True, thumbnail_quality=80, logo_width=500,\n        logo_height=200\n    )\n\n\ndef create_speaker_image_sizes():\n    get_or_create(\n        ImageSizes, type='speaker-image', icon_size_width_height=35, icon_size_quality=80,\n        small_size_width_height=50, small_size_quality=80,\n        thumbnail_size_width_height=500, thumbnail_quality=80\n    )\n\n\ndef create_modules():\n    get_or_create(Module, donation_include=False)\n\n\ndef create_event_topics():\n    event_topic = ['Health & Wellness', 'Home & Lifestyle',\n                   'Charity & Causes', 'Other', 'Religion & Spirituality',\n                   'Community & Culture', 'Government & Politics',\n                   'Government & Politics', 'Auto, Boat & Air',\n                   'Travel & Outdoor', 'Hobbies & Special Interest',\n                   'Sports & Fitness', 'Business & Professional',\n                   'Music', 'Seasonal & Holiday',\n                   'Film, Media & Entertainment', 'Family & Education',\n                   'Science & Technology', 'Performing & Visual Arts',\n                   'Food & Drink', 'Family & Education']\n    for topic in event_topic:\n        get_or_create(EventTopic, name=topic)\n\n\ndef create_event_types():\n    event_type = ['Camp, Treat & Retreat', 'Dinner or Gala',\n                  'Other', 'Concert or Performance', 'Conference',\n                  'Seminar or Talk', 'Convention',\n                  'Festival or Fair', 'Tour',\n                  'Screening', 'Game or Competition',\n                  'Party or Social Gathering', 'Race or Endurance Event',\n                  'Meeting or Networking Event', 'Attraction',\n                  'Class, Training, or Workshop', 'Appearance or Signing',\n                  'Tournament', 'Rally']\n    for type_ in event_type:\n        get_or_create(EventType, name=type_)\n\n\ndef create_event_locations():\n    event_location = ['India', 'Singapore', 'Berlin', 'New York', 'Hong Kong']\n    for loc_ in event_location:\n        get_or_create(EventLocation, name=loc_)\n\n\ndef create_permissions():\n    orgr = Role.query.get(1)\n    coorgr = Role.query.get(2)\n    track_orgr = Role.query.get(3)\n    mod = Role.query.get(4)\n    attend = Role.query.get(5)\n    regist = Role.query.get(6)\n\n    track = Service.query.get(1)\n    session = Service.query.get(2)\n    speaker = Service.query.get(3)\n    sponsor = Service.query.get(4)\n    microlocation = Service.query.get(5)\n\n    # For ORGANIZER\n    # All four permissions set to True\n    services = [track, session, speaker, sponsor, microlocation]\n    roles = [attend, regist]\n    for service in services:\n        perm, _ = get_or_create(Permission, role=orgr, service=service)\n        db.session.add(perm)\n\n    # For COORGANIZER\n    for service in services:\n        perm, _ = get_or_create(Permission, role=coorgr, service=service)\n        perm.can_create, perm.can_delete = False, False\n        db.session.add(perm)\n\n    # For TRACK_ORGANIZER\n    for service in services:\n        perm, _ = get_or_create(Permission, role=track_orgr, service=service)\n        if not service == track:\n            perm.can_create, perm.can_update, perm.can_delete = False, False, False\n        db.session.add(perm)\n\n    # For MODERATOR\n    for service in services:\n        perm, _ = get_or_create(Permission, role=mod, service=service)\n        perm.can_create, perm.can_update, perm.can_delete = False, False, False\n        db.session.add(perm)\n\n    # For ATTENDEE and REGISTRAR\n    services = [track, session, speaker, sponsor, microlocation]\n    roles = [attend, regist]\n    for role in roles:\n        for service in services:\n            perm, _ = get_or_create(Permission, role=role, service=service)\n            perm.can_create, perm.can_update, perm.can_delete = False, False, False\n            db.session.add(perm)\n\n\ndef create_custom_sys_roles():\n    role, _ = get_or_create(CustomSysRole, name='Sales Admin')\n    db.session.add(role)\n    role, _ = get_or_create(CustomSysRole, name='Marketer')\n    db.session.add(role)\n\n\ndef create_panel_permissions():\n    sales_admin = CustomSysRole.query.filter_by(name='Sales Admin').first()\n    perm, _ = get_or_create(PanelPermission, panel_name=SALES, role=sales_admin)\n    db.session.add(perm)\n    marketer = CustomSysRole.query.filter_by(name='Marketer').first()\n    perm, _ = get_or_create(PanelPermission, panel_name=SALES, role=marketer)\n    db.session.add(perm)\n\n\ndef create_user_permissions():\n    # Publish Event\n    user_perm, _ = get_or_create(UserPermission, name='publish_event',\n                                 description='Publish event (make event live)')\n    user_perm.verified_user = True\n    db.session.add(user_perm)\n\n    # Create Event\n    user_perm, _ = get_or_create(UserPermission, name='create_event',\n                                 description='Create event')\n    user_perm.verified_user, user_perm.unverified_user = True, False\n    db.session.add(user_perm)\n\n\ndef create_admin_message_settings():\n    default_mails = [\"Next Event\",\n                     \"Session Schedule Change\",\n                     \"User email\",\n                     \"Invitation For Papers\",\n                     \"After Event\",\n                     \"Ticket(s) Purchased\",\n                     \"Session Accept or Reject\",\n                     \"Event Published\",\n                     \"Event Export Failed\",\n                     \"Event Exported\",\n                     \"Event Role Invitation\",\n                     \"New Session Proposal\"]\n    for mail in MAILS:\n        if mail in default_mails:\n            get_or_create(MessageSettings, action=mail, mail_status=True,\n                          notification_status=True, user_control_status=True)\n        else:\n            get_or_create(\n                MessageSettings, action=mail, mail_status=False,\n                notification_status=False, user_control_status=False\n            )\n\n\ndef populate():\n    \"\"\"\n    Create defined Roles, Services and Permissions.\n    \"\"\"\n    print('Creating roles...')\n    create_roles()\n    print('Creating services...')\n    create_services()\n    print('Creating permissions...')\n    create_permissions()\n    print('Creating custom system roles...')\n    create_custom_sys_roles()\n    print('Creating admin panel permissions...')\n    create_panel_permissions()\n    print('Creating user permissions...')\n    create_user_permissions()\n    print('Creating settings...')\n    create_settings()\n    print('Creating modules...')\n    create_modules()\n    print('Creating event image size...')\n    create_event_image_sizes()\n    print('Creating speaker image size...')\n    create_speaker_image_sizes()\n    print('Creating Event Topics...')\n    create_event_topics()\n    print('Creating Event Types...')\n    create_event_types()\n    print('Creating Event Locations...')\n    create_event_locations()\n    print('Creating admin message settings...')\n    create_admin_message_settings()\n\n\ndef populate_without_print():\n    \"\"\"\n    Create defined Roles, Services and Permissions.\n    \"\"\"\n    create_roles()\n    create_services()\n    create_permissions()\n    create_custom_sys_roles()\n    create_panel_permissions()\n    create_user_permissions()\n    create_settings()\n    create_modules()\n    create_event_image_sizes()\n    create_speaker_image_sizes()\n    create_event_topics()\n    create_event_types()\n    create_event_locations()\n    create_admin_message_settings()\n\n    db.session.commit()\n\n\nif __name__ == '__main__':\n    with current_app.app_context():\n        populate()\n", "path": "populate_db.py"}]}