From 5cbd05b77766b53ea42f50c0600090db76917e02 Mon Sep 17 00:00:00 2001 From: Apoorva Pendse Date: Sat, 30 Nov 2024 07:43:11 +0530 Subject: [PATCH] org: Add slack bot integration to send timelog updates. --- .env.example | 4 + blt/settings.py | 2 + blt/urls.py | 4 +- .../company/add_slack_integration.html | 90 ++ .../company/company_includes/sidebar.html | 6 + .../company/company_integrations.html | 77 ++ company/urls.py | 12 + company/views.py | 217 +++- poetry.lock | 1007 +++++++++-------- pyproject.toml | 1 + website/admin.py | 4 + .../commands/slack_daily_timelogs.py | 81 ++ ...tegration_company_integrations_and_more.py | 83 ++ ...29_0712.py => 0161_merge_20241130_0114.py} | 4 +- ...ckintegration_bot_access_token_and_more.py | 17 + ...token_slackintegration_bot_access_token.py | 20 + website/models.py | 48 +- website/static/images/slack_icon.png | Bin 0 -> 39053 bytes 18 files changed, 1196 insertions(+), 481 deletions(-) create mode 100644 company/templates/company/add_slack_integration.html create mode 100644 company/templates/company/company_integrations.html create mode 100644 website/management/commands/slack_daily_timelogs.py create mode 100644 website/migrations/0160_alter_badge_icon_integration_company_integrations_and_more.py rename website/migrations/{0160_merge_20241129_0712.py => 0161_merge_20241130_0114.py} (58%) create mode 100644 website/migrations/0162_rename_access_token_slackintegration_bot_access_token_and_more.py create mode 100644 website/migrations/0163_rename_access_token_slackintegration_bot_access_token.py create mode 100644 website/static/images/slack_icon.png diff --git a/.env.example b/.env.example index 994ea9a16..f0231e541 100644 --- a/.env.example +++ b/.env.example @@ -22,3 +22,7 @@ DATABASE_URL=postgres://user:password@localhost:5432/dbname #Sentry DSN SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0 + + +SLACK_CLIENT_ID= +SLACK_CLIENT_SECRET= diff --git a/blt/settings.py b/blt/settings.py index 73188bd5a..12e6228a2 100644 --- a/blt/settings.py +++ b/blt/settings.py @@ -268,6 +268,8 @@ REPORT_EMAIL_PASSWORD = os.environ.get("REPORT_PASSWORD", "blank") # these settings are only for production / Heroku +TESTING = True +SECURE_SSL_REDIRECT = False if "DYNO" in os.environ: print("database url detected in settings") DEBUG = False diff --git a/blt/urls.py b/blt/urls.py index 486185fb6..2da525dc1 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -15,7 +15,7 @@ import comments.views from blt import settings -from company.views import ShowBughuntView +from company.views import ShowBughuntView, SlackCallbackView from website.api.views import ( ActivityLogViewSet, AuthApiViewset, @@ -232,11 +232,13 @@ path("auth/google/", GoogleLogin.as_view(), name="google_login"), path("accounts/github/login/callback/", github_callback, name="github_callback"), path("accounts/google/login/callback/", google_callback, name="google_callback"), + path("accounts/google/login/callback/", google_callback, name="google_callback"), path("accounts/facebook/login/callback/", facebook_callback, name="facebook_callback"), re_path(r"^auth/facebook/connect/$", FacebookConnect.as_view(), name="facebook_connect"), re_path(r"^auth/github/connect/$", GithubConnect.as_view(), name="github_connect"), re_path(r"^auth/google/connect/$", GoogleConnect.as_view(), name="google_connect"), path("auth/github/url/", github_views.oauth2_login), + path("oauth/slack/callback/", SlackCallbackView.as_view(), name="slack_callback"), path("auth/google/url/", google_views.oauth2_login), path("auth/facebook/url/", facebook_views.oauth2_callback), path("socialaccounts/", SocialAccountListView.as_view(), name="social_account_list"), diff --git a/company/templates/company/add_slack_integration.html b/company/templates/company/add_slack_integration.html new file mode 100644 index 000000000..1da0210d1 --- /dev/null +++ b/company/templates/company/add_slack_integration.html @@ -0,0 +1,90 @@ +{% extends "company/company_dashboard_base.html" %} +{% block title %} + Add Slack Integration +{% endblock title %} +{% block body %} +
+
+

Add Slack Integration

+
+
+ {% csrf_token %} +
+

Configure Slack Bot:

+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ + +
+
+
+ +
+
+
+ +
+
+ + + +{% endblock body %} diff --git a/company/templates/company/company_includes/sidebar.html b/company/templates/company/company_includes/sidebar.html index ff02c755f..b2ebfbdc3 100644 --- a/company/templates/company/company_includes/sidebar.html +++ b/company/templates/company/company_includes/sidebar.html @@ -42,6 +42,12 @@