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

Solution #508

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vscode/
*.iml
.env
frontend/.env
.DS_Store
venv/
.pytest_cache/
Expand Down
6 changes: 6 additions & 0 deletions backend/cinema_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"rest_framework",
"drf_spectacular",
"debug_toolbar",
"corsheaders",
"cinema",
"user",
]
Expand All @@ -54,6 +55,7 @@
"django.middleware.security.SecurityMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
Expand Down Expand Up @@ -175,3 +177,7 @@
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
"ROTATE_REFRESH_TOKENS": False,
}

CORS_ALLOWED_ORIGINS = [
"http://localhost:5174",
]
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
app:
build:
Expand All @@ -22,6 +20,6 @@ services:
db:
image: postgres:14-alpine
ports:
- "5432:5432"
- "5434:5432"
env_file:
- .env
41 changes: 38 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"axios": "^1.1.3",
"cors": "^2.8.5",
"jwt-decode": "^3.1.2",
"lodash.debounce": "^4.0.8",
"lodash.range": "^3.2.0",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
async fetchUser () {
const accessToken = localStorage.getItem('access');
try {
const { data: user } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/user/me`,
const { data: user } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/user/me/`,
{ headers: { Authorization: `Bearer ${accessToken}` } });

this.user = user;
Expand All @@ -87,7 +87,7 @@ export default {

async refreshToken () {
try {
const { data } = await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/token/refresh`, {
const { data } = await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/token/refresh/`, {
refresh: localStorage.getItem('refresh')
});

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/ActorListScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
methods: {
async fetchActors () {
try {
const { data: actors } = await axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/actors`, {
const { data: actors } = await axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/actors/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.actors = actors;
Expand All @@ -68,7 +68,7 @@ export default {
};

await axios.post(
`${import.meta.env.VITE_API_URL}/api/cinema/actors`,
`${import.meta.env.VITE_API_URL}/api/cinema/actors/`,
{
first_name: this.firstName,
last_name: this.lastName
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/CinemaHallAddScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
};
await axios.post(
`${import.meta.env.VITE_API_URL}/api/cinema/cinema_halls`,
`${import.meta.env.VITE_API_URL}/api/cinema/cinema_halls/`,
{
name: this.name,
rows: Number(this.countRows),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/CinemaHallListScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
methods: {
async fetchHalls () {
try {
const { data: halls } = await axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/cinema_halls`, {
const { data: halls } = await axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/cinema_halls/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.halls = halls;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/GenreListScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default {
methods: {
async fetchGenres () {
try {
const { data: genres } = await axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/genres`, {
const { data: genres } = await axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/genres/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.genres = genres;
Expand All @@ -64,7 +64,7 @@ export default {
};

await axios.post(
`${import.meta.env.VITE_API_URL}/api/cinema/genres`,
`${import.meta.env.VITE_API_URL}/api/cinema/genres/`,
{
name: this.name
},
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/MovieAddScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {

async fetchActors () {
try {
const { data: actors } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/actors`, {
const { data: actors } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/actors/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.actors = actors.map(({ id, first_name: firstName, last_name: lastName }) => {
Expand All @@ -78,7 +78,7 @@ export default {

async fetchGenres () {
try {
const { data: genres } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/genres`, {
const { data: genres } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/genres/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.genres = genres;
Expand Down Expand Up @@ -107,7 +107,7 @@ export default {
};

const { data: movie } = await axios.post(
`${import.meta.env.VITE_API_URL}/api/cinema/movies`,
`${import.meta.env.VITE_API_URL}/api/cinema/movies/`,
{
title: this.title,
duration: Number(this.duration),
Expand All @@ -121,7 +121,7 @@ export default {
if (this.image) {
const data = new FormData();
data.append('image', this.image);
await axios.post(`/api/cinema/movies-${movie.id}-upload-image`, data, imageConfig);
await axios.post(`${import.meta.env.VITE_API_URL}/api/cinema/movies/${movie.id}/upload-image/`, data, imageConfig);
}

location.hash = '#/movies';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/MovieDetailsScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {

async fetchMovie (id) {
try {
const { data: movie } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movies-${id}`, {
const { data: movie } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movies-${id}/`, {
headers: { Authorization: `Bearer ${this.token}` }
});

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/MovieListScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
methods: {
async fetchActors () {
try {
const { data: actors } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/actors`, {
const { data: actors } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/actors/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.actors = actors.map(({ id, first_name: firstName, last_name: lastName }) => {
Expand All @@ -76,7 +76,7 @@ export default {

async fetchGenres () {
try {
const { data: genres } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/genres`, {
const { data: genres } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/genres/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.genres = genres;
Expand All @@ -91,7 +91,7 @@ export default {
if (this.selectedGenreIds.length) params.genres = this.selectedGenreIds.join();

try {
const { data: movies } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movies`, {
const { data: movies } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movies/`, {
headers: { Authorization: `Bearer ${this.token}` },
params
});
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/MovieSessionAddScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {

async fetchMovies () {
try {
const { data: movies } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movies`, {
const { data: movies } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movies/`, {
headers: { Authorization: `Bearer ${this.token}` },
params: {}
});
Expand All @@ -70,7 +70,7 @@ export default {

async fetchCinemaHalls () {
try {
const { data: cinemaHalls } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/cinema_halls`, {
const { data: cinemaHalls } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/cinema_halls/`, {
headers: { Authorization: `Bearer ${this.token}` },
params: {}
});
Expand All @@ -95,7 +95,7 @@ export default {
};

await axios.post(
`${import.meta.env.VITE_API_URL}/api/cinema/movie_sessions`,
`${import.meta.env.VITE_API_URL}/api/cinema/movie_sessions/`,
{
movie: this.selectedMovieId,
cinema_hall: this.selectedHallId,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/MovieSessionDetailsScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
async fetchMovieSession (id) {
try {
this.loading = true;
const { data: session } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movie_sessions-${id}`, {
const { data: session } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movie_sessions-${id}/`, {
headers: { Authorization: `Bearer ${this.token}` }
});

Expand All @@ -95,7 +95,7 @@ export default {
}
};

await this.axios.post(`${import.meta.env.VITE_API_URL}/api/cinema/orders`, { tickets },
await this.axios.post(`${import.meta.env.VITE_API_URL}/api/cinema/orders/`, { tickets },
config
);
this.fetchMovieSession(this.movieSession.id);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/MovieSessionListScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default {

async fetchMovieSessionsByDate () {
try {
const { data: movieSessions } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movie_sessions`, {
const { data: movieSessions } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/movie_sessions/`, {
headers: { Authorization: `Bearer ${this.token}` },
params: {
date: this.date
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/OrderListScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {

async fetchOrders () {
try {
const { data: response } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/orders`, {
const { data: response } = await this.axios.get(`${import.meta.env.VITE_API_URL}/api/cinema/orders/`, {
headers: { Authorization: `Bearer ${this.token}` }
});
this.response = response;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/ProfileScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
if (this.password) body.password = this.password;

try {
const { data } = await this.axios.patch(`${import.meta.env.VITE_API_URL}/api/user/me`, body, config);
const { data } = await this.axios.patch(`${import.meta.env.VITE_API_URL}/api/user/me/`, body, config);
this.success = !!data;

this.email = '';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/SignIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
async signIn () {
try {
const { data } = await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/token`, {
const { data } = await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/token/`, {
email: this.email,
password: this.password
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/SignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export default {

async signUp () {
try {
await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/register`, {
await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/register/`, {
email: this.email,
password: this.password
});

const { data } = await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/token`, {
const { data } = await this.axios.post(`${import.meta.env.VITE_API_URL}/api/user/token/`, {
email: this.email,
password: this.password
});
Expand Down
Loading