Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Rename zerver/models.py to zerver/models/__init__.py.

Anders Kaseorge601d0ae7caf
diff --git a/docs/development/using.md b/docs/development/using.md
index d05a1ea9914..acb8b629b6f 100644
--- a/docs/development/using.md
+++ b/docs/development/using.md
@@ -47,7 +47,7 @@ the development environment][authentication-dev-server].
- The Python queue workers will also automatically restart when you
save changes, as long as they haven't crashed (which can happen if
they reloaded into a version with a syntax error).
-- If you change the database schema (`zerver/models.py`), you'll need
+- If you change the database schema (`zerver/models/*.py`), you'll need
to use the [Django migrations
process](../subsystems/schema-migrations.md); see also the [new
feature tutorial][new-feature-tutorial] for an example.
diff --git a/docs/overview/directory-structure.md b/docs/overview/directory-structure.md
index e146a827726..65f78d40c78 100644
--- a/docs/overview/directory-structure.md
+++ b/docs/overview/directory-structure.md
@@ -17,9 +17,9 @@ paths will be familiar to Django developers.
[Django routes file](https://docs.djangoproject.com/en/3.2/topics/http/urls/).
Defines which URLs are handled by which view functions or templates.
-- `zerver/models.py` Main
+- `zerver/models/*.py`
[Django models](https://docs.djangoproject.com/en/3.2/topics/db/models/)
- file. Defines Zulip's database tables.
+ files. Defines Zulip's database tables.
- `zerver/lib/*.py` Most library code.
diff --git a/docs/production/authentication-methods.md b/docs/production/authentication-methods.md
index 3575e65ad30..7247c93c918 100644
--- a/docs/production/authentication-methods.md
+++ b/docs/production/authentication-methods.md
@@ -365,7 +365,7 @@ You can look at the [full list of fields][models-py] in the Zulip user
model; search for `class UserProfile`, but the above should cover all
the fields that would be useful to sync from your LDAP databases.
-[models-py]: https://github.com/zulip/zulip/blob/main/zerver/models.py
+[models-py]: https://github.com/zulip/zulip/blob/main/zerver/models/__init__.py
[django-auth-booleans]: https://django-auth-ldap.readthedocs.io/en/latest/users.html#easy-attributes
### Multiple LDAP searches
diff --git a/docs/production/management-commands.md b/docs/production/management-commands.md
index b777501ae6f..f7259a39946 100644
--- a/docs/production/management-commands.md
+++ b/docs/production/management-commands.md
@@ -95,7 +95,7 @@ is already a function in `zerver.actions` with a name like
`do_change_full_name` that updates that field and notifies clients
correctly.
-For convenience, Zulip automatically imports `zerver/models.py`
+For convenience, Zulip automatically imports `zerver.models`
into every management shell; if you need to
access other functions, you'll need to import them yourself.
diff --git a/docs/subsystems/caching.md b/docs/subsystems/caching.md
index d1742d9c406..9228681eb6f 100644
--- a/docs/subsystems/caching.md
+++ b/docs/subsystems/caching.md
@@ -131,7 +131,7 @@ you configure some code to run every time Django does something (for
`post_save`, right after any write to the database using Django's
`.save()`).
-There's a handful of lines in `zerver/models.py` like these that
+There's a handful of lines in `zerver/models/*.py` like these that
configure this:
```python
diff --git a/docs/subsystems/schema-migrations.md b/docs/subsystems/schema-migrations.md
index 3499e3858e5..ebde9eff1aa 100644
--- a/docs/subsystems/schema-migrations.md
+++ b/docs/subsystems/schema-migrations.md
@@ -9,9 +9,9 @@ This page documents some important issues related to writing schema
migrations.
- If your database migration is just to reflect new fields in
- `models.py`, you'll typically want to just:
+ `models/*.py`, you'll typically want to just:
- Rebase your branch before you start (this may save work later).
- - Update the model class definitions in `zerver/models.py`.
+ - Update the model class definitions in `zerver/models/*.py`.
- Run `./manage.py makemigrations` to generate a migration file
- Rename the migration file to have a descriptive name if Django
generated used a date-based name like `0089_auto_20170710_1353.py`
@@ -33,7 +33,7 @@ migrations.
- If your migrations were automatically generated using
`manage.py makemigrations`, a good option is to just remove your
migration and rerun the command after rebasing. Remember to
- `git rebase` to do this in the the commit that changed `models.py`
+ `git rebase` to do this in the the commit that changed `models/*.py`
if you have a multi-commit branch.
- If you wrote code as part of preparing your migrations, or prefer
this workflow, you can use run `./tools/renumber-migrations`,
diff --git a/docs/subsystems/typing-indicators.md b/docs/subsystems/typing-indicators.md
index 75e29cf4bc9..6ecf0468d33 100644
--- a/docs/subsystems/typing-indicators.md
+++ b/docs/subsystems/typing-indicators.md
@@ -37,7 +37,7 @@ On a high level the typing indicators system works like this:
Note that there is a user-level privacy setting to disable sending
typing notifications that a client should check when implementing
the "writing user" protocol below. See `send_private_typing_notifications`
-in the `UserBaseSettings` model in `zerver/models.py` and in the
+in the `UserBaseSettings` model in `zerver/models/__init__.py` and in the
`user_settings` object in the `POST /register` response.
## Writing user
diff --git a/docs/testing/testing.md b/docs/testing/testing.md
index 146cb5cfdc1..06040c817b9 100644
--- a/docs/testing/testing.md
+++ b/docs/testing/testing.md
@@ -32,7 +32,7 @@ because it takes a long time. Instead, your edit/refresh cycle will
typically involve running subsets of the tests with commands like these:
```bash
-./tools/lint zerver/models.py # Lint the file you just changed
+./tools/lint zerver/models/__init__.py # Lint the file you just changed
./tools/test-backend zerver.tests.test_markdown.MarkdownTest.test_inline_youtube
./tools/test-backend MarkdownTest # Run `test-backend --help` for more options
./tools/test-js-with-node util
@@ -60,7 +60,7 @@ eventually work with, each with its own page detailing how it works:
Additionally, Zulip also has about a dozen smaller tests suites:
- `tools/test-migrations`: Checks whether the `zerver/migrations`
- migration content the models defined in `zerver/models.py`. See our
+ migration content the models defined in `zerver/models/*.py`. See our
[schema migration documentation](../subsystems/schema-migrations.md)
for details on how to do database migrations correctly.
- `tools/test-documentation`: Checks for broken links in this
diff --git a/docs/tutorials/new-feature-tutorial.md b/docs/tutorials/new-feature-tutorial.md
index e871f2a5526..6345753fe44 100644
--- a/docs/tutorials/new-feature-tutorial.md
+++ b/docs/tutorials/new-feature-tutorial.md
@@ -35,7 +35,7 @@ organization in Zulip). The following files are involved in the process:
**Backend**
-- `zerver/models.py`: Defines the database model.
+- `zerver/models/__init__.py`: Defines the database model.
- `zerver/views/realm.py`: The view function that implements the API endpoint
for editing realm objects.
- `zerver/actions/realm_settings.py`: Contains code for updating and interacting with the database.
@@ -73,7 +73,7 @@ organization in Zulip). The following files are involved in the process:
### Adding a field to the database
**Update the model:** The server accesses the underlying database in
-`zerver/models.py`. Add a new field in the appropriate class.
+`zerver/models/__init__.py`. Add a new field in the appropriate class.
**Create and run the migration:** To create and apply a migration, run the
following commands:
@@ -185,10 +185,10 @@ task of requiring messages to have a topic, you can [view this commit](https://g
First, update the database and model to store the new setting. Add a new
boolean field, `mandatory_topics`, to the Realm model in
-`zerver/models.py`.
+`zerver/models/__init__.py`.
```diff
- # zerver/models.py
+ # zerver/models/__init__.py
class Realm(models.Model):
# ...
@@ -205,7 +205,7 @@ is the field's type. Add the new field to the `property_types`
dictionary.
```diff
- # zerver/models.py
+ # zerver/models/__init__.py
class Realm(models.Model)
# ...
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index f8d92fb1abc..1599123dff5 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -409,7 +409,7 @@ python_rules = RuleList(
},
{
"pattern": r": *(?!Optional)[^\n ].*= models[.].*null=True",
- "include_only": {"zerver/models.py"},
+ "include_only": {"zerver/models/"},
"description": "Model variable with null=true not annotated as Optional.",
"good_lines": [
"desc: Optional[Text] = models.TextField(null=True)",
@@ -425,7 +425,7 @@ python_rules = RuleList(
{
"pattern": r": *Optional.*= models[.].*\)",
"exclude_pattern": "null=True",
- "include_only": {"zerver/models.py"},
+ "include_only": {"zerver/models/"},
"description": "Model variable annotated with Optional but variable does not have null=true.",
"good_lines": [
"desc: Optional[Text] = models.TextField(null=True)",
diff --git a/tools/test-queue-worker-reload b/tools/test-queue-worker-reload
index 9ea4661cdb9..5d5080babab 100755
--- a/tools/test-queue-worker-reload
+++ b/tools/test-queue-worker-reload
@@ -88,7 +88,7 @@ if __name__ == "__main__":
time.sleep(1.3)
print("Attempting to modify a file")
- os.utime("zerver/models.py")
+ os.utime("zerver/models/__init__.py")
failed = check_worker_launch(run_dev)
run_dev.send_signal(signal.SIGINT)
diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts
index 7beb24a5ad8..8868941bcfa 100644
--- a/web/src/settings_config.ts
+++ b/web/src/settings_config.ts
@@ -1006,7 +1006,7 @@ export const stream_privacy_policy_values = {
export const stream_post_policy_values = {
// These strings should match the strings in the
- // Stream.POST_POLICIES object in zerver/models.py.
+ // Stream.POST_POLICIES object in zerver/models/__init__.py.
everyone: {
code: StreamPostPolicy.EVERYONE,
description: $t({defaultMessage: "Everyone"}),
diff --git a/web/tests/bot_data.test.js b/web/tests/bot_data.test.js
index e6b6c035432..c1ac83e95e0 100644
--- a/web/tests/bot_data.test.js
+++ b/web/tests/bot_data.test.js
@@ -10,7 +10,7 @@ const bot_data = zrequire("bot_data");
const people = zrequire("people");
// Bot types and service bot types can be found
-// in zerver/models.py - UserProfile Class or
+// in zerver/models/__init__.py - UserProfile Class or
// zever/openapi/zulip.yaml
const me = {
diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.py
index 7a88ad2d6ea..d724ab1ddaf 100644
--- a/zerver/data_import/rocketchat.py
+++ b/zerver/data_import/rocketchat.py
@@ -182,7 +182,7 @@ def convert_channel_data(
# should be allowed to post in the converted Zulip stream.
# For more details: https://zulip.com/help/stream-sending-policy
#
- # See `Stream` model in `zerver/models.py` to know about what each
+ # See `Stream` model in `zerver/models/__init__.py` to know about what each
# number represent.
stream_post_policy = 4 if channel_dict.get("ro", False) else 1
@@ -886,7 +886,7 @@ def map_receiver_id_to_recipient_id(
user_id_to_recipient_id[recipient["type_id"]] = recipient["id"]
-# This is inspired by get_huddle_hash from zerver/models.py. It
+# This is inspired by get_huddle_hash from zerver/models/__init__.py. It
# expects strings identifying Rocket.Chat users, like
# `LdBZ7kPxtKESyHPEe`, not integer IDs.
#
diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py
index b72a8e97c1d..87da24e641e 100644
--- a/zerver/lib/cache.py
+++ b/zerver/lib/cache.py
@@ -554,7 +554,7 @@ def changed(update_fields: Optional[Sequence[str]], fields: List[str]) -> bool:
return any(f in update_fields_set for f in fields)
-# Called by models.py to flush the user_profile cache whenever we save
+# Called by models/__init__.py to flush the user_profile cache whenever we save
# a user_profile object
def flush_user_profile(
*,
@@ -591,7 +591,7 @@ def flush_muting_users_cache(*, instance: "MutedUser", **kwargs: object) -> None
cache_delete(get_muting_users_cache_key(mute_object.muted_user_id))
-# Called by models.py to flush various caches whenever we save
+# Called by models/__init__.py to flush various caches whenever we save
# a Realm object. The main tricky thing here is that Realm info is
# generally cached indirectly through user_profile objects.
def flush_realm(
@@ -639,7 +639,7 @@ def realm_text_description_cache_key(realm: "Realm") -> str:
return f"realm_text_description:{realm.string_id}"
-# Called by models.py to flush the stream cache whenever we save a stream
+# Called by models/__init__.py to flush the stream cache whenever we save a stream
# object.
def flush_stream(
*,
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index c594365140d..a9bb5380b95 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -453,7 +453,7 @@ def fetch_initial_state_data(
assert spectator_requested_language is not None
# When UserProfile=None, we want to serve the values for various
# settings as the defaults. Instead of copying the default values
- # from models.py here, we access these default values from a
+ # from models/__init__.py here, we access these default values from a
# temporary UserProfile object that will not be saved to the database.
#
# We also can set various fields to avoid duplicating code
diff --git a/zerver/lib/export.py b/zerver/lib/export.py
index e25edbb1e58..9549b5f42bb 100644
--- a/zerver/lib/export.py
+++ b/zerver/lib/export.py
@@ -307,7 +307,7 @@ DATE_FIELDS: Dict[TableName, List[Field]] = {
def sanity_check_output(data: TableData) -> None:
# First, we verify that the export tool has a declared
- # configuration for every table declared in the `models.py` files.
+ # configuration for every table declared in the `models` modules.
target_models = [
*apps.get_app_config("analytics").get_models(include_auto_created=True),
*apps.get_app_config("django_otp").get_models(include_auto_created=True),
diff --git a/zerver/migrations/0298_fix_realmauditlog_format.py b/zerver/migrations/0298_fix_realmauditlog_format.py
index d63496e9916..893c4d799e2 100644
--- a/zerver/migrations/0298_fix_realmauditlog_format.py
+++ b/zerver/migrations/0298_fix_realmauditlog_format.py
@@ -31,7 +31,7 @@ def update_realmauditlog_values(apps: StateApps, schema_editor: BaseDatabaseSche
}
"""
RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")
- # Constants from models.py
+ # Constants from models/__init__.py
USER_DEFAULT_SENDING_STREAM_CHANGED = 129
USER_DEFAULT_REGISTER_STREAM_CHANGED = 130
USER_DEFAULT_ALL_PUBLIC_STREAMS_CHANGED = 131
diff --git a/zerver/migrations/0468_rename_followup_day_email_templates.py b/zerver/migrations/0468_rename_followup_day_email_templates.py
index 56532243b83..6f77b0e9dfb 100644
--- a/zerver/migrations/0468_rename_followup_day_email_templates.py
+++ b/zerver/migrations/0468_rename_followup_day_email_templates.py
@@ -6,7 +6,7 @@ from django.db.migrations.state import StateApps
from django.db.models import F, Func, JSONField, TextField, Value
from django.db.models.functions import Cast
-# ScheduledMessage.type for onboarding emails from zerver/models.py
+# ScheduledMessage.type for onboarding emails from zerver/models/__init__.py
WELCOME = 1
diff --git a/zerver/models.py b/zerver/models/__init__.py
similarity index 100%
rename from zerver/models.py
rename to zerver/models/__init__.py