From f5b655adaa70f035bea5e391261aea6e07a18c68 Mon Sep 17 00:00:00 2001 From: Altafur Rahman Date: Sat, 21 Dec 2024 20:32:58 +0600 Subject: [PATCH] rename 'company' to 'organization' in templates and URLs (#3143) --- blt/urls.py | 124 ++++++++++-------- website/signals.py | 17 ++- website/static/company/js/hunt_controller.js | 4 +- website/static/js/scripts.js | 12 +- .../templates/admin_dashboard_company.html | 4 +- .../bughunt/company_manage_bughunts.html | 8 +- .../templates/company/company_analytics.html | 6 +- .../company/company_includes/navbar.html | 2 +- .../company/company_includes/sidebar.html | 12 +- .../company/company_manage_roles.html | 2 +- .../company_dashboard_hunt_detail.html | 2 +- website/templates/company_domain_lists.html | 2 +- website/templates/domain.html | 2 +- website/templates/hunt_drafts.html | 2 +- website/templates/hunt_previous.html | 2 +- website/templates/includes/admin_sidenav.html | 2 +- .../templates/includes/company_sidenav.html | 4 +- website/templates/includes/header.html | 2 +- website/templates/includes/navbar.html | 2 +- website/templates/includes/sidenav.html | 4 +- website/templates/sitemap.html | 32 ++--- website/views/company.py | 42 +++--- 22 files changed, 156 insertions(+), 133 deletions(-) diff --git a/blt/urls.py b/blt/urls.py index 0757f5026..41c7631a2 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -260,9 +260,9 @@ urlpatterns = [ path("", home, name="home"), path( - "api/v1/companies/", + "api/v1/organizations/", OrganizationViewSet.as_view({"get": "list", "post": "create"}), - name="company", + name="organization", ), path("invite-friend/", invite_friend, name="invite_friend"), path("referral/", referral_signup, name="referral_signup"), @@ -290,7 +290,9 @@ 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"), - path("add_domain_to_company/", add_domain_to_organization, name="add_domain_to_company"), + path( + "add_domain_to_organization/", add_domain_to_organization, name="add_domain_to_organization" + ), path( "socialaccounts//disconnect/", SocialAccountDisconnectView.as_view(), @@ -309,9 +311,9 @@ re_path(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"), re_path(r"^issues/$", newhome, name="issues"), re_path( - r"^dashboard/company/$", + r"^dashboard/organization/$", organization_dashboard, - name="company_dashboard_home", + name="organization_dashboard_home", ), re_path( r"^dashboard/user/profile/addbalance$", @@ -325,29 +327,29 @@ name="stripe_connected", ), re_path( - r"^dashboard/admin/company$", + r"^dashboard/admin/organization$", admin_organization_dashboard, - name="admin_company_dashboard", + name="admin_organization_dashboard", ), re_path( - r"^dashboard/admin/company/addorupdate$", + r"^dashboard/admin/organization/addorupdate$", add_or_update_organization, - name="add_or_update_company", + name="add_or_update_organization", ), re_path( - r"^dashboard/company/domain/addorupdate$", + r"^dashboard/organization/domain/addorupdate$", add_or_update_domain, name="add_or_update_domain", ), path( - "dashboard/company/domain//", + "dashboard/organization/domain//", organization_dashboard_domain_detail, - name="company_dashboard_domain_detail", + name="organization_dashboard_domain_detail", ), path( - "dashboard/company/hunt//", + "dashboard/organization/hunt//", organization_dashboard_hunt_detail, - name="company_dashboard_hunt_detail", + name="organization_dashboard_hunt_detail", ), path("dashboard/user/hunt//", view_hunt, name="view_hunt"), path( @@ -361,52 +363,52 @@ name="hunt_results", ), path( - "dashboard/company/hunt//edit", + "dashboard/organization/hunt//edit", organization_dashboard_hunt_edit, - name="company_dashboard_hunt_edit", + name="organization_dashboard_hunt_edit", ), path( - "dashboard/admin/company//", + "dashboard/admin/organization//", admin_organization_dashboard_detail, - name="admin_company_dashboard_detail", + name="admin_organization_dashboard_detail", ), - re_path(r"^dashboard/company/hunt/create$", CreateHunt.as_view(), name="create_hunt"), + re_path(r"^dashboard/organization/hunt/create$", CreateHunt.as_view(), name="create_hunt"), path("hunt/", ShowBughuntView.as_view(), name="show_bughunt"), - re_path(r"^dashboard/company/hunt/drafts$", DraftHunts.as_view(), name="draft_hunts"), + re_path(r"^dashboard/organization/hunt/drafts$", DraftHunts.as_view(), name="draft_hunts"), re_path( - r"^dashboard/company/hunt/upcoming$", + r"^dashboard/organization/hunt/upcoming$", UpcomingHunts.as_view(), name="upcoming_hunts", ), re_path( - r"^dashboard/company/hunt/previous$", + r"^dashboard/organization/hunt/previous$", PreviousHunts.as_view(), name="previous_hunts", ), path( - "dashboard/company/hunt/previous//", + "dashboard/organization/hunt/previous//", organization_hunt_results, - name="company_hunt_results", + name="organization_hunt_results", ), re_path( - r"^dashboard/company/hunt/ongoing$", + r"^dashboard/organization/hunt/ongoing$", OngoingHunts.as_view(), name="ongoing_hunts", ), - re_path(r"^dashboard/company/domains$", DomainList.as_view(), name="domain_list"), + re_path(r"^dashboard/organization/domains$", DomainList.as_view(), name="domain_list"), re_path( - r"^dashboard/company/settings$", + r"^dashboard/organization/settings$", OrganizationSettings.as_view(), - name="company-settings", + name="organization-settings", ), re_path(r"^join$", Joinorganization.as_view(), name="join"), re_path( - r"^dashboard/company/settings/role/update$", + r"^dashboard/organization/settings/role/update$", update_role, name="update-role", ), re_path( - r"^dashboard/company/settings/role/add$", + r"^dashboard/organization/settings/role/add$", add_role, name="add-role", ), @@ -652,68 +654,78 @@ # users path("users/", users_view, name="users"), # company specific urls : - path("company/", RegisterOrganizationView.as_view(), name="register_company"), - path("company/dashboard/", Organization_view, name="company_view"), + path("organization/", RegisterOrganizationView.as_view(), name="register_organization"), + path("organization/dashboard/", Organization_view, name="organization_view"), path( - "company//dashboard/analytics/", + "organization//dashboard/analytics/", OrganizationDashboardAnalyticsView.as_view(), - name="company_analytics", + name="organization_analytics", ), path( - "company//dashboard/integrations/", + "organization//dashboard/integrations/", OrganizationDashboardIntegrations.as_view(), - name="company_manage_integrations", + name="organization_manage_integrations", ), path( - "company//dashboard/bugs/", + "organization//dashboard/bugs/", OrganizationDashboardManageBugsView.as_view(), - name="company_manage_bugs", + name="organization_manage_bugs", ), path( - "company//dashboard/domains/", + "organization//dashboard/domains/", OrganizationDashboardManageDomainsView.as_view(), - name="company_manage_domains", + name="organization_manage_domains", ), path( - "company//dashboard/roles/", + "organization//dashboard/roles/", OrganizationDashboardManageRolesView.as_view(), - name="company_manage_roles", + name="organization_manage_roles", ), path( - "company//dashboard/bughunts/", + "organization//dashboard/bughunts/", OrganizationDashboardManageBughuntView.as_view(), - name="company_manage_bughunts", + name="organization_manage_bughunts", + ), + path( + "organization/dashboard/end_bughunt/", EndBughuntView.as_view(), name="end_bughunt" ), - path("company/dashboard/end_bughunt/", EndBughuntView.as_view(), name="end_bughunt"), - path("company//dashboard/add_bughunt/", AddHuntView.as_view(), name="add_bughunt"), - path("company//dashboard/add_domain/", AddDomainView.as_view(), name="add_domain"), + path("organization//dashboard/add_bughunt/", AddHuntView.as_view(), name="add_bughunt"), + path("organization//dashboard/add_domain/", AddDomainView.as_view(), name="add_domain"), path( - "company//dashboard/add_slack_integration/", + "organization//dashboard/add_slack_integration/", AddSlackIntegrationView.as_view(), name="add_slack_integration", ), path( - "company//dashboard/edit_domain//", + "organization//dashboard/edit_domain//", AddDomainView.as_view(), name="edit_domain", ), - path("company/domain//", login_required(DomainView.as_view()), name="view_domain"), - path("company/delete_prize//", delete_prize, name="delete_prize"), - path("company/edit_prize//", edit_prize, name="edit_prize"), - path("company/accept_bug///", accept_bug, name="accept_bug"), + path("organization/domain//", login_required(DomainView.as_view()), name="view_domain"), + path( + "organization/delete_prize//", + delete_prize, + name="delete_prize", + ), + path( + "organization/edit_prize//", + edit_prize, + name="edit_prize", + ), + path("organization/accept_bug///", accept_bug, name="accept_bug"), path( - "company/accept_bug///", + "organization/accept_bug///", accept_bug, name="accept_bug_no_reward", ), path( - "company/delete_manager///", + "organization/delete_manager///", delete_manager, name="delete_manager", ), path("sponsor/", sponsor_view, name="sponsor"), path("donate/", donate_view, name="donate"), - path("companies/", DomainListView.as_view(), name="domain_lists"), + path("organizations/", DomainListView.as_view(), name="domain_lists"), path("trademarks/", trademark_search, name="trademark_search"), path("generate_bid_image//", generate_bid_image, name="generate_bid_image"), path("bidding/", SaveBiddingData, name="BiddingData"), diff --git a/website/signals.py b/website/signals.py index 43e40f19d..62bc9b2d2 100644 --- a/website/signals.py +++ b/website/signals.py @@ -74,9 +74,20 @@ def handle_post_save(sender, instance, created, **kwargs): assign_first_action_badge(instance.user, "First Bug Reported") create_activity(instance, "created") - elif sender == Hunt and created: # Track first bid placed - assign_first_action_badge(instance.user, "First Bug Bounty") - create_activity(instance, "created") + elif sender == Hunt and created: # Track first bug bounty + # Attempt to get the user from Domain managers or Organization + user = None + if instance.domain: + # Try managers of the domain + user = instance.domain.managers.first() + # Optionally, if Organization has a user, fetch it here + if not user and instance.domain.organization: + user = getattr(instance.domain.organization, "user", None) + + # Assign badge and activity if a user is found + if user: + assign_first_action_badge(user, "First Bug Bounty") + create_activity(instance, "created") elif sender == Suggestion and created: # Track first suggestion assign_first_action_badge(instance.user, "First Suggestion") diff --git a/website/static/company/js/hunt_controller.js b/website/static/company/js/hunt_controller.js index 91efc4c78..7da36bc31 100644 --- a/website/static/company/js/hunt_controller.js +++ b/website/static/company/js/hunt_controller.js @@ -221,7 +221,7 @@ function removePrize(event, prizeId, companyId) { prizeContainer.appendChild(loadingIndicator); // Make AJAX call to delete the prize with company_id - fetch(`/company/delete_prize/${prizeId}/${companyId}`, { + fetch(`/organization/delete_prize/${prizeId}/${companyId}`, { method: 'DELETE', headers: { 'X-CSRFToken': getCookie('csrftoken') @@ -284,7 +284,7 @@ function updatePrize(prizeId, companyId) { } // Make AJAX call to update the prize with company_id - fetch(`/company/edit_prize/${prizeId}/${companyId}`, { + fetch(`/organization/edit_prize/${prizeId}/${companyId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/website/static/js/scripts.js b/website/static/js/scripts.js index 094d73549..4f908540b 100644 --- a/website/static/js/scripts.js +++ b/website/static/js/scripts.js @@ -20,7 +20,7 @@ console.log(serializedData) $.ajax({ type: 'POST', - url: "/dashboard/company/settings/role/update", + url: "/dashboard/organization/settings/role/update", data: serializedData, success: function (response) { window.location.reload(); @@ -46,7 +46,7 @@ var value = ($( this ).serializeArray())[1].value; $.ajax({ type: 'POST', - url: "/dashboard/company/hunt/"+value+"/edit", + url: "/dashboard/organization/hunt/"+value+"/edit", data: serializedData, success: function (response) { window.location.reload(); @@ -113,7 +113,7 @@ serializedData.push({name:"date2", value: date2}); $.ajax({ type: 'POST', - url: "/dashboard/company/hunt/create", + url: "/dashboard/organization/hunt/create", data: $.param(serializedData), success: function (response) { window.location.reload(); @@ -131,7 +131,7 @@ console.log(serializedData) $.ajax({ type: 'POST', - url: "/dashboard/company/settings/role/add", + url: "/dashboard/organization/settings/role/add", data: serializedData, success: function (response) { window.location.reload(); @@ -150,7 +150,7 @@ console.log(serializedData) $.ajax({ type: 'POST', - url: "/dashboard/admin/company/addorupdate", + url: "/dashboard/admin/organization/addorupdate", data: serializedData, success: function (response) { window.location.reload(); @@ -169,7 +169,7 @@ console.log(serializedData) $.ajax({ type: 'POST', - url: "/dashboard/company/domain/addorupdate", + url: "/dashboard/organization/domain/addorupdate", data: serializedData, success: function (response) { console.log(response) diff --git a/website/templates/admin_dashboard_company.html b/website/templates/admin_dashboard_company.html index 11251c3cb..518f928ef 100644 --- a/website/templates/admin_dashboard_company.html +++ b/website/templates/admin_dashboard_company.html @@ -26,10 +26,10 @@ Organization {% for company in companys %} {% if company.is_active %} - {{ company.name }} {% else %} - {{ company.name }} {% endif %} {% endfor %} diff --git a/website/templates/company/bughunt/company_manage_bughunts.html b/website/templates/company/bughunt/company_manage_bughunts.html index 4695e7b28..86457404e 100644 --- a/website/templates/company/bughunt/company_manage_bughunts.html +++ b/website/templates/company/bughunt/company_manage_bughunts.html @@ -51,19 +51,19 @@

Bughunts

diff --git a/website/templates/company/company_analytics.html b/website/templates/company/company_analytics.html index 574999e16..8cecf2da2 100644 --- a/website/templates/company/company_analytics.html +++ b/website/templates/company/company_analytics.html @@ -26,7 +26,7 @@
- +

{{ total_info.total_domains }}

Domains

diff --git a/website/templates/company/company_includes/navbar.html b/website/templates/company/company_includes/navbar.html index 9b7fc432b..4bbdd120a 100644 --- a/website/templates/company/company_includes/navbar.html +++ b/website/templates/company/company_includes/navbar.html @@ -68,7 +68,7 @@

Organizations

{% for company in companies %} - {{ company_obj.name | slice:":15" | c