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

V3 beta #283

Merged
merged 36 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4e2d784
Merge pull request #260 from Wizarrrr/v3-beta
realashleybailey Oct 19, 2023
b7b22af
Merge pull request #261 from Wizarrrr/v3-beta
realashleybailey Oct 19, 2023
e0d5fdd
Merge pull request #262 from Wizarrrr/v3-beta
realashleybailey Oct 19, 2023
188bc67
Merge pull request #263 from Wizarrrr/v3-beta
realashleybailey Oct 19, 2023
fbba312
Update README.md
realashleybailey Oct 19, 2023
3a8104a
Update README.md
realashleybailey Oct 19, 2023
33932f6
Update README.md
realashleybailey Oct 24, 2023
97af6d7
refactor(invitations): Refactor creating and managing invitations
realashleybailey Oct 25, 2023
eef5ee8
Merge pull request #277 from Wizarrrr/translations
realashleybailey Oct 25, 2023
4d333a4
feat: Add support for syncing users from Jellyfin server
realashleybailey Oct 25, 2023
fc9a8eb
Update
realashleybailey Oct 26, 2023
460bd3b
fix
realashleybailey Oct 26, 2023
f8ab2b3
Refactor server and requests code for improved functionality and read…
realashleybailey Oct 26, 2023
d8386f6
Added noscript
realashleybailey Oct 26, 2023
9681841
Refactor authentication code for better readability
realashleybailey Oct 26, 2023
0119016
Refactor Carousel.vue component
realashleybailey Oct 26, 2023
08cd565
Refactor Discord component styling and use translation strings
realashleybailey Oct 26, 2023
1b3fb96
Update Download.vue component
realashleybailey Oct 26, 2023
8df1415
feat: Add Request component
realashleybailey Oct 26, 2023
5d11597
Add RequestsList component
realashleybailey Oct 26, 2023
99172d3
Refactor Jellyfin Welcome.vue component UI
realashleybailey Oct 26, 2023
f219aac
feat: Add dynamic views to Help page
realashleybailey Oct 26, 2023
d672ead
Refactor Requests component to improve code readability and style con…
realashleybailey Oct 26, 2023
a449e91
Refactor RequestsItem.vue component, optimizing code and improving bu…
realashleybailey Oct 26, 2023
6dc7273
Refactor modal.ts for improved flexibility and usability
realashleybailey Oct 26, 2023
996fc41
Add debug logging for ModalWrapper attrs in development mode
realashleybailey Oct 26, 2023
17d77c1
fix(sentry): Update Sentry integration configuration
realashleybailey Oct 26, 2023
21e3365
Refactor requests.ts to use single-quote string literals and improve …
realashleybailey Oct 26, 2023
b2afd31
Refactor server store and update server data handling.
realashleybailey Oct 26, 2023
08bd93f
refactor(create.py): Updated the file path for the version file
realashleybailey Oct 28, 2023
3e34072
Remove "EasterEggs" plugin from the main.ts file.
realashleybailey Oct 28, 2023
ab02f8a
feat: Add migration scripts and update database schema
realashleybailey Oct 29, 2023
ab8093a
Update project configuration file and lock dependencies
realashleybailey Oct 29, 2023
e6cee77
Remove unnecessary command to create a directory in project.json
realashleybailey Oct 29, 2023
e8cf5f2
make dir
realashleybailey Oct 29, 2023
6b82fe6
Merge branch 'master' into v3-beta
realashleybailey Oct 29, 2023
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<a href="https://features.wizarr.dev">
<img alt="Submit Feature Requests" src="https://img.shields.io/badge/fider-vote%20on%20features-success.svg"/>
</a>
<a href="https://github.com/Wizarrrr/wizarr/actions/workflows/ci.yml">
<img alt="Github Build" src="https://img.shields.io/github/actions/workflow/status/wizarrrr/wizarr/ci.yml"/>
<a href="https://github.com/Wizarrrr/wizarr/actions/workflows/release.yml">
<img alt="Github Build" src="https://img.shields.io/github/actions/workflow/status/wizarrrr/wizarr/release.yml"/>
</a>
</p>

Expand All @@ -53,6 +53,10 @@ Wizarr is a automatic user invitation system for Plex and Jellyfin. Create a uni

Wizarr V2 has moved to the v2 branch [here](https://github.com/Wizarrrr/wizarr/tree/v2), your still more than welcome to use v2 however it will no longer be supported, we recommend using our new version, trust us it's 🔥.

## V3 upgradable from V2?

V3 can now support upgrading from V2, please make a backup of your database.db for the safest upgrade path.

## Major Features Include

- Automatic Invitation to your Media Server (Plex, Jellyfin)
Expand Down
6 changes: 3 additions & 3 deletions apps/wizarr-backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"executor": "@nxlv/python:run-commands",
"options": {
"commands": [
"mkdir -p ../database",
"DB_DIR=../database poetry run flask run --debug"
"make-dir ../database",
"poetry run flask run --debug"
],
"cwd": "apps/wizarr-backend/wizarr_backend"
}
Expand Down Expand Up @@ -78,4 +78,4 @@
}
},
"tags": []
}
}
2 changes: 2 additions & 0 deletions apps/wizarr-backend/wizarr_backend/api/routes/server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def get(self):
from app import app
from app.security import is_setup_required
from helpers.settings import get_settings
from helpers.requests import get_requests

resp = {
"settings": get_settings(disallowed=["server_api_key"]),
"requests": get_requests(disallowed=["api_key"]),
"version": str(get_current_version()),
"update_available": need_update(),
"debug": True if app.debug else False,
Expand Down
3 changes: 2 additions & 1 deletion apps/wizarr-backend/wizarr_backend/app/migrator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def run_migrations():

# Get the base directory
BASE_DIR = path.abspath(path.join(path.dirname(path.realpath(__file__)), "../", "../"))
MIGRATIONS_DIR = path.abspath(path.join(path.realpath(__file__), "../", "migrations"))

# Get the current migrations in the database
current_migrations = [migration.name for migration in Migrations.select()]

# Run the migrations in the migrations folder based on their filenames date and time from oldest to newest
for migration in sorted(listdir(path.join(BASE_DIR, "app", "migrator", "migrations"))):
for migration in sorted(listdir(MIGRATIONS_DIR)):
# Skip if it does not end with .py
if not migration.endswith(".py"):
continue
Expand Down
2 changes: 1 addition & 1 deletion apps/wizarr-backend/wizarr_backend/app/migrator/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def get_current_version():
# File path to the version file
version_file = path.join(path.dirname(path.realpath(__file__)), "../", "../", "../", "latest")
version_file = path.abspath(path.join(path.dirname(path.realpath(__file__)), "../", "../", "../", "../", "../", "latest"))

# Read the current version
with open(version_file, "r") as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run():
db.execute_sql("DELETE FROM settings WHERE key = 'admin_password'")

# Create the new account using the old credentials
db.execute_sql(f"INSERT INTO accounts (username, password, role) VALUES ('{admin_username}', '{admin_password}', 'admin')")
db.execute_sql(f"INSERT INTO accounts (username, password, role, tutorial) VALUES ('{admin_username}', '{admin_password}', 'admin', 0)")

# Remove admin_key from the settings table
with db.transaction():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# CREATED ON VERSION: V3.4.2
# MIGRATION: 2023-10-28_19-21-23
# CREATED: Sat Oct 28 2023
#

from peewee import *
from playhouse.migrate import *

from app import db

# Do not change the name of this file,
# migrations are run in order of their filenames date and time

def run():
# Use migrator to perform actions on the database
migrator = SqliteMigrator(db)

# Add columns name server_id to requests table
with db.transaction():
# Check if the column exists
cursor = db.cursor()
cursor.execute("PRAGMA table_info(requests);")
columns = cursor.fetchall()
column_names = [column[1] for column in columns]

if 'name' not in column_names:
db.execute_sql("ALTER TABLE requests ADD COLUMN name TEXT")
else:
print("Column name already exists")

if 'server_id' not in column_names:
db.execute_sql("ALTER TABLE requests ADD COLUMN server_id TEXT DEFAULT 0")
else:
print("Column server_id already exists")


print("Migration 2023-10-28_19-21-23 complete")
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# CREATED ON VERSION: V3.4.2
# MIGRATION: 2023-10-29_16-35-41
# CREATED: Sun Oct 29 2023
#

from peewee import *
from playhouse.migrate import *

from app import db

# Do not change the name of this file,
# migrations are run in order of their filenames date and time

def run():
# Use migrator to perform actions on the database
migrator = SqliteMigrator(db)

# Add columns auth to users table
with db.transaction():
# Check if the column exists
cursor = db.cursor()
cursor.execute("PRAGMA table_info(users);")
columns = cursor.fetchall()
column_names = [column[1] for column in columns]

if 'auth' not in column_names:
db.execute_sql("ALTER TABLE users ADD COLUMN auth TEXT")
else:
print("Column auth already exists")

print("Migration 2023-10-29_16-35-41 complete")
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ def create_code():
if isinstance(invitation["specific_libraries"], list):
invitation["specific_libraries"] = ",".join(invitation["specific_libraries"])


# invitation["expires"] = None
# invitation["duration"] = None

# If expires is a string or int, convert it to a utc datetime plus the total minutes
if invitation["expires"] and isinstance(invitation["expires"], (str, int)):
invitation["expires"] = datetime.utcnow() + timedelta(minutes=int(str(invitation["expires"])))
Expand All @@ -127,6 +123,8 @@ def create_code():
if invitation["duration"] and isinstance(invitation["duration"], (str, int)):
invitation["duration"] = datetime.utcnow() + timedelta(minutes=int(str(invitation["duration"])))

invitation["created"] = datetime.utcnow()

# Create the invitation in the database
invite: Invitations = Invitations.create(**invitation)

Expand Down
16 changes: 16 additions & 0 deletions apps/wizarr-backend/wizarr_backend/helpers/requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from app.models.database import Requests
from playhouse.shortcuts import model_to_dict
from json import loads, dumps

def get_requests(disallowed: list[str] = None):
# Get all requests from the database
requests = list(Requests.select().dicts())

# Remove disallowed requests keys
if disallowed is not None:
for request in requests:
for key in disallowed:
del request[key]

# Return the requests
return loads(dumps(requests, indent=4, sort_keys=True, default=str))
7 changes: 5 additions & 2 deletions apps/wizarr-backend/wizarr_backend/helpers/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ def global_sync_users_to_media_server() -> dict[str]:
# Sync users from the media server to the database
if server_type == "plex":
sync_plex_users()
elif server_type == "jellyfin":

if server_type == "jellyfin":
sync_jellyfin_users()

# Return response
Expand All @@ -235,7 +236,8 @@ def global_get_user_profile_picture(user_id: str) -> str:
# Get the user"s profile picture from the media server
if server_type == "plex":
return get_plex_profile_picture(user_id)
elif server_type == "jellyfin":

if server_type == "jellyfin":
return get_jellyfin_profile_picture(user_id)

# Raise an error if the user"s profile picture is None
Expand Down Expand Up @@ -342,6 +344,7 @@ def global_invite_user_to_media_server(**kwargs) -> dict[str]:
Users.expires: invite.duration,
Users.auth: kwargs.get("token", None),
Users.email: user.email if server_type == "plex" else kwargs.get("email", None),
Users.created: datetime.utcnow()
})

# Add the user to the database
Expand Down
Loading