Added all previous GSOC organizations to organizations
Closes: https://github.com/OWASP-BLT/BLT/issues/3264 Work-in progress PR (I haven't added consistent UI yet so the cards aren't displayed properly, please don't mind that)
https://github.com/user-attachments/assets/7bd00617-d8da-44c1-93a9-0130ec4e31e0
Summary by CodeRabbit
- New Features
- Introduced a dedicated endpoint and page to display information for unverified domains, making it easier to view domain details for specific organizations.
- Style
- Revamped the domain listing interface with updated card layouts, improved pagination, and new visual cues (including default logos and unverified badges) for a clearer and more engaging user experience.
@DonnieBLT sir, while adding the organizations, I encountered the following problem: Since, an organization's domains are linked to their BLT profile, and not their slug. I'll have to either create a new slug field in Domains model in models.py file or I'll have to manually register each of the organizations domain and then link their domain, so as to create their BLT profile. Can you please guide me on how should I pursue this further ahead? thank you.
Approach to Follow:
-
Since an organization's domains are linked to their BLT profile, you need to update the model first.
-
As we haven’t linked domains to BLT profiles yet, we need to be very cautious with the code. Initially, when creating an organization manually, we will not assign any specific user to it.
-
In the future, if a manager or admin comes to BLT to create an organization account, we will check whether their organization (without a user) already exists in our system. This verification will be done using their email address.
-
If the organization already exists, we will ask them to confirm ownership. This can be done via OTP verification or by checking whether the user is already verified.
-
Once verified, the user can then be linked to their organization.
Points to Consider:
-
First, remove the
website/fixtures/merged_organizations.jsonfile, as it is not a robust approach. Instead, write a script to fetch the data and apply conditions to ensure all data is updated yearly. Also, consider the script's complexity and execution time. -
Make changes to the
domainlist.htmlfile and the organization view file only if absolutely necessary. For now, I believe you should focus only on making changes to the organization creation process and ensuring the necessary condition checks mentioned earlier are implemented.
@DonnieBLT , could you please provide your feedback on this suggestion? Also, let me know if there's anything you'd like to add or remove.
@tsu-ki , if you have any questions, feel free to ask—I'm here !
Sounds good!
Approach to Follow:
- Since an organization's domains are linked to their BLT profile, you need to update the model first.
- As we haven’t linked domains to BLT profiles yet, we need to be very cautious with the code. Initially, when creating an organization manually, we will not assign any specific user to it.
- In the future, if a manager or admin comes to BLT to create an organization account, we will check whether their organization (without a user) already exists in our system. This verification will be done using their email address.
- If the organization already exists, we will ask them to confirm ownership. This can be done via OTP verification or by checking whether the user is already verified.
- Once verified, the user can then be linked to their organization.
Points to Consider:
- First, remove the
website/fixtures/merged_organizations.jsonfile, as it is not a robust approach. Instead, write a script to fetch the data and apply conditions to ensure all data is updated yearly. Also, consider the script's complexity and execution time.- Make changes to the
domainlist.htmlfile and the organization view file only if absolutely necessary. For now, I believe you should focus only on making changes to the organization creation process and ensuring the necessary condition checks mentioned earlier are implemented.@DonnieBLT , could you please provide your feedback on this suggestion? Also, let me know if there's anything you'd like to add or remove.
@tsu-ki , if you have any questions, feel free to ask—I'm here !
@JisanAR03 thank you so much for your extensive explanation, it cleared a lot of things for me.
Firstly, I would like to address my approach to solving this. I was considering re-introducing slug field and using conditional statements, where if an org's domain isn't linked to their BLT profile page yet, a slug is created for that org and instead that slug can be linked to their profile page.
So, following route would be followed for gsoc orgs present under website/fixtures/merged_organizations.json:
org url fetched from json file -> check if their domain is linked or not -> if not, slug is created for this org, and instead slug is linked to their BLT page.
Secondly, I created multiple scripts to scrap org information but since gsoc archive doesn't contain information about orgs which participated before 2016, I had to scrap per year information, which didn't include data fields such as logo and correct urls. website/fixtures/merged_organizations.json was formed after combining multiple json files.
I tried using Bing API, which is professionally used for web scraping, but it couldn't provide satisfactory results and took too much time to execute. plus, the cost be a factor aswell. I do agree that it's not a robust approach but I haven't been able to find a better approach yet. If you can help me with this, I would be very grateful.
@DonnieBLT sir, please review this and guide me on this, thank you!
@tsu-ki , please consider :
- verifying an organization before linking it to a user as i mention before, ensuring accurate mapping.
2 . Using slugs as a workaround for missing domain links might lead to inconsistencies in future updates. and keeps the organization-user mapping clean without introducing unnecessary fields.
-
focus on refining the organization creation process with careful condition checks.
-
Give me the script you were testing with. Let me check. If I can't do anything with that, then we will go with your approach.
@tsu-ki , please consider :
- verifying an organization before linking it to a user as i mention before, ensuring accurate mapping.
2 . Using slugs as a workaround for missing domain links might lead to inconsistencies in future updates. and keeps the organization-user mapping clean without introducing unnecessary fields.
- focus on refining the organization creation process with careful condition checks.
- Give me the script you were testing with. Let me check. If I can't do anything with that, then we will go with your approach.
I've shared the script with you on slack, please look into it. I'll create a minimal process which checks whether an org exists in the DB or not, if it does then whether it's domain is linked or not. I'll have to find my way around for saving the JSON file organisations and using their domains correctly. thank you for your help!
@JisanAR03 @DonnieBLT I've created a seperate class that handles unverified organizations using path("domain/<str:org_name>/unverified", UnverifiedDomainView.as_view(), name="domain_unverified"), route.
- Both verified(organizations whose domains have been linked with their BLT profiles and unverified(organizations without verification); are displayed on Organizations page, unverified org having an
unverified tagattached. - An unverified organization is determined as unverified, if it does not exist in DB and has been fetched from another source.
- When user redirects to an unverified organization's domain, they're taken to a different page, which shows that they're unverified.
- Incorporating this required changes only in
organizations.py,domain_list.html,.urls.pyand creating a new template file. Please review this approach and suggest how can I improve, make changes to it. thank you!
https://github.com/user-attachments/assets/d01cfb76-de23-4bef-9246-280260d8023e
can you please add a new field in the organisation table for gsoc_years for a comma separated list - and update all the css to tailwind? Also we don't need the unverified domainview anymore as we will have a new organization page soon.
sure, I'll make the required changes and update PR. I'm shifting to a new place, so it might take me a couple of days to complete this. I hope that won't be a problem, thank you for your understanding
can you please add a new field in the organisation table for gsoc_years for a comma separated list - and update all the css to tailwind? Also we don't need the unverified domainview anymore as we will have a new organization page soon.
sure, I'll make the required changes and update PR. I'm shifting to a new place, so it might take me a couple of days to complete this. I hope that won't be a problem, thank you for your understanding
Sounds good! Good luck with the move!
/kudos
this is a bit outdated now, feel free to revise it and make it work for the new layout this could be one script - see the recent gsoc import
@coderabbitai please make the changes
Walkthrough
This pull request introduces new functionality for handling unverified organization domains. A new URL pattern and corresponding view have been added to route requests for unverified domains. The domain management logic has been updated to merge verified domains from the database with unverified ones sourced from a JSON file, modify pagination, and redirect unverified domain detail requests appropriately. Additionally, the domain listing interface has been redesigned with updated HTML templates and styling improvements, and a new template has been added for unverified domains.
Changes
| File(s) | Change Summary |
|---|---|
blt/urls.pywebsite/views/organization.py |
Added new URL route for unverified domains and introduced the UnverifiedDomainView. Updated DomainListView to merge database domains with unverified data from a JSON file, increased pagination from 20 to 30 items, and modified DomainDetailView to redirect unverified domains and adjust issue retrieval. |
website/templates/domain_list.htmlwebsite/templates/unverified_domain.html |
Redesigned domain listing layout by updating grid styling with a fixed column width, new card structure, added styling classes (.unverified-badge, .years, .pagination), revised logo display logic, and introduced a new template (unverified_domain.html) to present details for unverified domains. |
Sequence Diagram(s)
sequenceDiagram
participant U as User
participant R as URL Router
participant UD as UnverifiedDomainView
participant T as Unverified Domain Template
U->>R: Request /domain/{org_name}/unverified
R->>UD: Route request to UnverifiedDomainView
UD->>UD: Load unverified organization data from JSON
alt Organization found
UD->>T: Render unverified_domain.html with org details
else Organization not found
UD->>U: Return Http404 error
end
sequenceDiagram
participant U as User
participant R as URL Router
participant DD as DomainDetailView
participant UD as UnverifiedDomainView
participant T as Template
U->>R: Request domain detail
R->>DD: Process detail request
DD->>DD: Check domain verification status
alt Domain is unverified
DD->>UD: Redirect to UnverifiedDomainView
UD->>T: Render unverified_domain.html
else Domain is verified
DD->>T: Render verified domain details with issues using updated pagination
end
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
[!TIP] For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Let's first understand the PR changes
git show --name-only
# Look for the organization model
fd "models.py" | xargs grep -l "class Organization" || fd "models.py" | xargs grep -l "organization"
# Look for recent GSOC import scripts or related files
fd "gsoc.*import" || fd "import.*gsoc" || fd -e py | xargs grep -l "gsoc" | grep -v test
# Check the current PR branch files
git ls-files | grep -E "organization|gsoc"
Length of output: 65793
🏁 Script executed:
#!/bin/bash
# Find the organization model
cat website/models.py | grep -A 20 "class Organization" || cat website/models.py | grep -A 20 "class Company"
# Look for recent GSOC import scripts
fd -e py | xargs grep -l "gsoc" | head -10
# Look at the merged_organizations.json file mentioned in earlier comments
cat website/fixtures/merged_organizations.json | head -20
# Check if there's a recent commit related to GSOC import
git log --grep="gsoc" -n 5 --oneline
Length of output: 2966
🏁 Script executed:
#!/bin/bash
# Look for more recent GSOC import scripts and files
git log --grep="gsoc import" -n 5 --oneline
git log --grep="organization" -n 5 --oneline
# Search for all files containing 'gsoc' in their content
fd -e py | xargs grep -l "gsoc" | grep -v test
# Let's see if there are any migration files for adding fields to the Organization model
fd "migrations" | grep -l "Organization" | xargs grep -l "add_field"
# Look at any recent commits touching the organization model or fixtures
git log --oneline -n 10 website/models.py
git log --oneline -n 10 website/fixtures/merged_organizations.json
# Check for any recent commits that might be related to the new layout mentioned
git log --oneline -n 20 | grep -i layout
Length of output: 155
🏁 Script executed:
#!/bin/bash
# Check the Organization model definition
cat website/models.py | grep -A 30 "class Organization"
# Check the merged_organizations.json file format
head -30 website/fixtures/merged_organizations.json
# Look for related code
grep -r "gsoc.*import" --include="*.py" .
# Check for recent changes related to organization layout
git log -p -n 1 --grep="organization"
# Let's examine the current PR branch changes
git diff HEAD^ HEAD
Length of output: 4044
🏁 Script executed:
#!/bin/bash
# Let's create a migration file to add the gsoc_years field to the Organization model
echo "
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('website', '0184_merge_0183_merge_20250124_0618_0183_slackbotactivity'),
]
operations = [
migrations.AddField(
model_name='organization',
name='gsoc_years',
field=models.CharField(blank=True, max_length=255, null=True, help_text='Comma-separated list of years participated in Google Summer of Code'),
),
]
" > website/migrations/0185_organization_gsoc_years.py
# Let's find files related to the organization view or template
fd -e html | grep -i organization
fd -e py | grep -i organization
# Look for any templates that might need CSS update to Tailwind
fd -e html | grep -i domain
Length of output: 2952
@DonnieBLT I'll implement the requested changes based on our previous discussions. Here's what I'll do:
- I've already added a migration file for the new
gsoc_yearsfield to the Organization model:
# website/migrations/0185_organization_gsoc_years.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('website', '0184_merge_0183_merge_20250124_0618_0183_slackbotactivity'),
]
operations = [
migrations.AddField(
model_name='organization',
name='gsoc_years',
field=models.CharField(blank=True, max_length=255, null=True, help_text='Comma-separated list of years participated in Google Summer of Code'),
),
]
-
I'll update the CSS in the relevant templates to use Tailwind instead of traditional CSS, particularly focusing on
domain_list.htmland related organization templates. -
I'll remove the unverified domainview as you mentioned a new organization page is coming soon.
-
I'll modify the import script to utilize the data from the
merged_organizations.jsonfile to populate the Organization model with the GSOC organizations and their participation years.
Let me know if there are any specific requirements or considerations for the implementation.
/giphy nice to have
