forked from Sefaria/Sefaria-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
567 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pymongo import MongoClient | ||
|
||
# Replace the URI string with your MongoDB connection string | ||
connection_string = "mongodb://localhost:27017/" # For a local instance | ||
# For MongoDB Atlas, your connection string might look like: | ||
# connection_string = "mongodb+srv://<username>:<password>@cluster0.mongodb.net/test?retryWrites=true&w=majority" | ||
|
||
# Create a MongoClient | ||
client = MongoClient(connection_string) | ||
|
||
# Access a database | ||
db = client['sefaria'] | ||
|
||
# Access a collection | ||
index_collection = db['index'] | ||
|
||
|
||
documents = index_collection.find() | ||
texts = [] | ||
|
||
for doc in documents: | ||
texts.append({ | ||
'title': doc['title'], | ||
'text_category': doc['categories'], | ||
}) | ||
|
||
update_result = db['text_permission_groups'].update_one( | ||
{"name": "default"}, # Query to find the document | ||
{"$push": {"texts": {"$each": texts}}} # Use $push with $each to add multiple items | ||
) | ||
|
||
# Print the result | ||
if update_result.modified_count > 0: | ||
print("Texts added successfully.") | ||
else: | ||
print("No matching document found or no update performed.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
from django import template | ||
from django.conf import settings | ||
|
||
register = template.Library() | ||
|
||
@register.simple_tag | ||
def versioned_static(file_path): | ||
full_path = os.path.join(settings.BASE_DIR, 'static', file_path) | ||
try: | ||
timestamp = int(os.path.getmtime(full_path)) | ||
return f"{settings.STATIC_URL}{file_path}?v={timestamp}" | ||
except FileNotFoundError: | ||
return f"{settings.STATIC_URL}{file_path}" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.