Skip to content

Commit 054155a

Browse files
committed
Updating settings
1 parent 684ca30 commit 054155a

3 files changed

Lines changed: 42 additions & 13 deletions

File tree

accounts/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class EditProfileForm(forms.ModelForm):
5353
full_name = forms.CharField(
5454
max_length=30,
5555
widget=forms.TextInput(attrs={'placeholder': 'Full Name'}),
56-
label='')
56+
label='Name')
5757
slack_display_name = forms.CharField(
5858
max_length=30,
5959
widget=forms.TextInput(attrs={'placeholder': 'Slack Display Name'}),
60-
label='')
60+
label='Slack Display Name')
6161
current_lms_module = forms.CharField(
6262
widget=forms.Select(choices=LMS_MODULES_CHOICES),
6363
label="Where are you currently in the programme?"

docker-compose.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525

2626
environment:
2727
- ENV_FILE=/hackathon-app/.env
28-
- DEVELOPMENT=1
28+
- STATIC_URL=https://codeinstitute-webpublic.s3.eu-west-1.amazonaws.com/hackathon_staticfiles/1.62-a/
2929
entrypoint: ['python3', 'manage.py', 'runserver', '0.0.0.0:8000']
3030
ports:
3131
- "8000:8000"
@@ -64,13 +64,3 @@ services:
6464
image: redis:6.2.4
6565
ports:
6666
- "6379:6379"
67-
68-
worker:
69-
<<: *hackathon-app-main
70-
entrypoint: ["celery", "-A", "main", "worker", "-l", "INFO"]
71-
ports: []
72-
73-
# environment:
74-
# - ENV_FILE=/hackathon-app/.env
75-
# volumes:
76-
# - ./.env:/hackathon-app/.env

hackathon/tasks.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99

1010
from accounts.models import EmailTemplate, SlackSiteSettings
1111

12+
from celery import shared_task
13+
from django.conf import settings
14+
15+
from accounts.models import CustomUser as User
16+
from hackathon.models import Hackathon
17+
from custom_slack_provider.slack import CustomSlackClient
18+
1219
logger = logging.getLogger(__name__)
20+
logger.setLevel(logging.INFO)
1321

1422

1523
@shared_task
@@ -34,3 +42,34 @@ def send_email_from_template(user_email, user_name, hackathon_display_name, temp
3442
"Please create it on the Django Admin Panel"))
3543
except SMTPException:
3644
logger.exception("There was an issue sending the email.")
45+
def log_user_numbers():
46+
users = User.objects.count()
47+
logger.info(f'Number of users currently: {users}')
48+
return
49+
50+
51+
@shared_task
52+
def create_new_slack_channel(hackathon_id, channel_name):
53+
""" Create a new Slack Channel/Conversation in an existing Workspace """
54+
if not settings.SLACK_ENABLED:
55+
logger.info("Slack not enabled.")
56+
return
57+
58+
hackathon = Hackathon.objects.get(id=hackathon_id)
59+
logger.info(
60+
(f"Creating new Slack channel {channel_name} for hackathon "
61+
f"{hackathon.display_name} in Slack Workspace "
62+
f"{settings.SLACK_WORKSPACE}({settings.SLACK_TEAM_ID})"))
63+
slack_client = CustomSlackClient(settings.SLACK_BOT_TOKEN)
64+
channel_id = slack_client.create_slack_channel(
65+
channel_name, is_private=True)
66+
logger.info(f"Channel with id {channel_id} created.")
67+
68+
if not channel_id:
69+
logger.error("No Channel Id found.")
70+
return
71+
72+
channel_url = f'https://{settings.SLACK_WORKSPACE}.slack.com/archives/{channel_id}' # noqa: E501
73+
hackathon.channel_url = channel_url
74+
hackathon.save()
75+
logger.info(f"Hackathon {hackathon.display_name} updated successfully.")

0 commit comments

Comments
 (0)