When a new event is deployed, there are a lot of things that are done for that event automatically. These include creating an event website, creating an email address for the event, adding organizers of the event listed in the event application to the event as well as inviting these organizers, if they are new organizers, to join Django Girls Slack Channel.
Here we share how and where in the code for our website the new organizers are currently being added to Slack.
The process through the code is:
EventApplication.deploy()
(here)Event.add_organizer(organizer.email, organizer.first_name, organizer.last_name)
(here & here)Event.invite_organizer_to_team(user, created, password)
(here)User.invite_to_slack()
(here)user_invite(self.email, self.first_name)
(here)
And finally:
def user_invite(email, first_name):
return slack.users.post('users.admin.invite', params={
'email': email,
'first_name': first_name,
'set_active': True
})
The email used here is the value in the core.User
model.
The process is as follows:
-
Deploy event - This is handled by the
EventApplication.deploy()
method. This method creates a new Event or clones the previous Event if it exists. It also adds the main organizer of the event to the Event and adds the co-organizers as well.TODO - remove previous organizers if they are not part of the new organizers.
-
Add organizers to Event - This is handled by the Event.add_organizer() method. This method is called for each organizer in the EventApplication. It creates an account for new organizers if a user with that email does not exist already or gets the user and adds them to the new event. It also calls the
Event.invite_organizer_to_the_team()
method. -
Invite the organizer to the team - This is handled by the
Event.invite_organizer_to_team()
method. The method calls theUser.invite_to_slack()
method and notifies the user that they have been added to an event, sending them their login details. -
Invite the user to slack - This is handled by the
User.invite_to_slack()
method and it only calls theuser_invite()
function fromslack_client.py
. -
Inviting the user to slack - This is handled by the
user_invite()
function which takes the user's first name and email and posts them to the Slack API, setting the user'sset_active
status toTrue
.
Usually all the processes of deploying an event and organizers work up to the point of inviting organizers to Slack. Many organizers do not get their invites to Slack. Should this happen, they can be added manually if they reach out to [email protected]
by following the guidelines given here.
At the moment, Slacker API is being used to integrate our website to Slack. However, since Slacker was archived in 2020 because Slack had developed their own API, work is being done to move from Slacker to Slack API.