Skip to content

Commit

Permalink
Merge branch 'main' into ip-reports
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnieBLT authored Nov 11, 2024
2 parents e5d4ad5 + 64e3b18 commit de564c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 5 additions & 2 deletions website/views/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def add_domain_to_company(request):
company = Company.objects.filter(name=company_name).first()

if not company:
response = requests.get(domain.url)
url = domain.url
if not url.startswith(("http://", "https://")):
url = "http://" + url
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
if company_name in soup.get_text():
company = Company.objects.create(name=company_name)
Expand All @@ -71,7 +74,7 @@ def add_domain_to_company(request):
messages.success(request, "Organization added successfully")
return redirect("domain", slug=domain.url)
else:
return redirect("index")
return redirect("home")


@login_required(login_url="/accounts/login")
Expand Down
12 changes: 5 additions & 7 deletions website/views/project.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import json
import re
from datetime import datetime, timedelta, timezone
from datetime import datetime, timedelta
from pathlib import Path

import requests
from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.timezone import now
from django.views.generic import DetailView, ListView
from PIL import Image, ImageDraw, ImageFont
from rest_framework.views import APIView
Expand Down Expand Up @@ -87,9 +88,6 @@ def post(self, request, *args, **kwargs):

elif "refresh_contributors" in request.POST:
call_command("fetch_contributors", "--project_id", project.pk)
messages.success(request, f"Refreshing contributors for {project.name}")
return redirect("project_view", slug=project.slug)

return redirect("project_view", slug=project.slug)

def get(self, request, *args, **kwargs):
Expand All @@ -100,7 +98,7 @@ def get(self, request, *args, **kwargs):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
end_date = timezone.now()
end_date = now()
display_end_date = end_date.date()
selected_year = self.request.GET.get("year", None)
if selected_year:
Expand Down Expand Up @@ -151,7 +149,7 @@ def get_context_data(self, **kwargs):

user_stats = dict(sorted(user_stats.items(), key=lambda x: x[1]["total"], reverse=True))

current_year = timezone.now().year
current_year = now().year
year_list = list(range(current_year, current_year - 10, -1))

context.update(
Expand All @@ -168,7 +166,7 @@ def get_context_data(self, **kwargs):


class ProjectBadgeView(APIView):
def get(self, request, slug, format=None):
def get(self, request, slug):
# Retrieve the project or return 404
project = get_object_or_404(Project, slug=slug)

Expand Down

0 comments on commit de564c7

Please sign in to comment.