Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Merge requests
!91
Resolve "Upload pictures"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Upload pictures"
98-upload-pictures
into
dev
Overview
0
Commits
17
Pipelines
1
Changes
2
Merged
Josef Olsson
requested to merge
98-upload-pictures
into
dev
4 years ago
Overview
0
Commits
17
Pipelines
1
Changes
2
Expand
Closes
#98 (closed)
0
0
Merge request reports
Viewing commit
90b97740
Prev
Next
Show latest version
2 files
+
7
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
90b97740
Fix back-end tests
· 90b97740
Josef Olsson
authored
4 years ago
server/app/database/controller/add.py
+
22
−
2
Options
@@ -2,10 +2,11 @@
This file contains functionality to add data to the database.
"""
from
sqlalchemy.orm.session
import
sessionmaker
import
os
import
app.core.http_codes
as
codes
from
app.core
import
db
from
app.database.controller
import
utils
from
app.database.controller
import
get
,
search
,
utils
from
app.database.models
import
(
Blacklist
,
City
,
@@ -25,8 +26,12 @@ from app.database.models import (
User
,
ViewType
,
)
from
flask.globals
import
current_app
from
flask_restx
import
abort
from
PIL
import
Image
from
sqlalchemy
import
exc
from
sqlalchemy.orm
import
relation
from
sqlalchemy.orm.session
import
sessionmaker
def
db_add
(
item
):
@@ -97,6 +102,21 @@ def component(type_id, slide_id, data, x=0, y=0, w=0, h=0):
Adds a component to the slide at the specified coordinates with the
provided size and data .
"""
from
app.apis.media
import
PHOTO_PATH
if
type_id
==
2
:
# 2 is image
item_image
=
get
.
one
(
Media
,
data
[
"
media_id
"
])
filename
=
item_image
.
filename
path
=
os
.
path
.
join
(
PHOTO_PATH
,
filename
)
with
Image
.
open
(
path
)
as
im
:
h
=
im
.
height
w
=
im
.
width
largest
=
max
(
w
,
h
)
if
largest
>
600
:
ratio
=
600
/
largest
w
*=
ratio
h
*=
ratio
return
db_add
(
Component
(
slide_id
,
type_id
,
data
,
x
,
y
,
w
,
h
))
Loading