Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 6 #1

Merged
merged 8 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p align="center"><a href="https://github.com/OWASP/BLT/actions" rel="noopener noreferrer" target="__blank"><img alt="Build" src="https://github.com/OWASP/BLT/actions/workflows/auto-merge.yml/badge.svg"></a> <a href="https://github.com/OWASP/BLT/blob/main/LICENSE.md" rel="noopener noreferrer"><img src="https://img.shields.io/badge/license-AGPL--3.0-blue"></a>
<a href="https://github.com/OWASP/BLT" rel="noopener noreferrer" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/OWASP/BLT?style=social"></a></p>

<img alt="Views" src="https://blt.owasp.org/projects/blt/badge"></a>
[![Visitor Badge](https://visit-counter-y3x4.onrender.com//badge/BLT)](https://visit-counter-y3x4.onrender.com//badge/BLT)

------
Everything is on our <a href="https://blt.owasp.org">homepage</a>
Everything is on our <a href="https://blt.owasp.org">homepage</a>
10 changes: 10 additions & 0 deletions blt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"dj_rest_auth",
"dj_rest_auth.registration",
"blog",
"corsheaders",
)


Expand All @@ -121,8 +122,17 @@
"whitenoise.middleware.WhiteNoiseMiddleware",
"tz_detect.middleware.TimezoneMiddleware",
"blt.middleware.ip_restrict.IPRestrictMiddleware",
"corsheaders.middleware.CorsMiddleware",
)

CORS_ALLOWED_ORIGINS = [
"http://localhost:41455",
"http://localhost:8082",
# Add other origins as necessary
]

CORS_ALLOW_CREDENTIALS = True # Allow credentials to be included in requests

TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"

if DEBUG and not TESTING:
Expand Down
430 changes: 227 additions & 203 deletions company/templates/company/register_company.html

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions website/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ def short_description(self, obj):
admin.site.unregister(User)


class RecommendationAdmin(admin.ModelAdmin):
list_display = ("recommender", "recommended_user", "created_at")
search_fields = ("recommender__username", "recommended_user__username")


class UserAdmin(ImportExportModelAdmin):
resource_class = UserResource
list_display = (
Expand Down Expand Up @@ -245,6 +250,7 @@ class UserProfileAdmin(admin.ModelAdmin):
"flagged_count",
"subscribed_domains_count",
"subscribed_users_count",
"recommendation_count",
"x_username",
"linkedin_url",
"github_url",
Expand Down Expand Up @@ -273,6 +279,9 @@ def subscribed_domains_count(self, obj):
def subscribed_users_count(self, obj):
return obj.subscribed_users.count()

def recommendation_count(self, obj):
return obj.recommendations.count()


class IssueScreenshotAdmin(admin.ModelAdmin):
model = IssueScreenshot
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("website", "0153_delete_contributorstats"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Recommendation",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"recommended_user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="received_recommendations",
to=settings.AUTH_USER_MODEL,
),
),
(
"recommender",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="given_recommendations",
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.AddConstraint(
model_name="recommendation",
constraint=models.UniqueConstraint(
fields=("recommender", "recommended_user"), name="unique_recommendation"
),
),
]
22 changes: 22 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,28 @@ def __str__(self):
return f"ActivityLog by {self.user.username} at {self.recorded_at}"


class Recommendation(models.Model):
recommender = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="given_recommendations"
)
recommended_user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="received_recommendations"
)
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
constraints = [
models.UniqueConstraint(
fields=["recommender", "recommended_user"], name="unique_recommendation"
)
]

def __str__(self):
return (
f"Recommendation from {self.recommender.username} to {self.recommended_user.username}"
)


class DailyStatusReport(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateField()
Expand Down
1 change: 1 addition & 0 deletions website/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Meta:
"issue_flaged",
"total_score",
"activities",
"recommendations",
)


Expand Down
Loading
Loading