Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
소
소공_캠픽스
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
이예빈
소공_캠픽스
Commits
445eeccb
Commit
445eeccb
authored
3 years ago
by
Kangmin Lee
Browse files
Options
Downloads
Patches
Plain Diff
신고기능구현
parent
34681548
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
campics_/jinstagram/views.py
+21
-14
21 additions, 14 deletions
campics_/jinstagram/views.py
with
21 additions
and
14 deletions
campics_/jinstagram/views.py
+
21
−
14
View file @
445eeccb
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
content.models
import
Feed
,
Reply
,
FeedLike
,
FeedView
,
Bookmark
from
content.models
import
Feed
,
Reply
,
FeedLike
,
FeedView
,
FeedReport
,
Bookmark
from
user.models
import
User
,
Follow
,
Univ
from
user.models
import
User
,
Follow
,
Univ
from
django.db.models
import
Count
,
Sum
from
django.db.models
import
Count
,
Sum
class
Main
(
APIView
):
class
Main
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
email
=
request
.
session
.
get
(
'
email
'
,
None
)
email
=
request
.
session
.
get
(
'
email
'
,
None
)
...
@@ -64,6 +65,7 @@ class Main(APIView):
...
@@ -64,6 +65,7 @@ class Main(APIView):
user
=
user
,
user
=
user
,
type
=
type
))
type
=
type
))
class
Post
(
APIView
):
class
Post
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
email
=
request
.
session
.
get
(
'
email
'
,
None
)
email
=
request
.
session
.
get
(
'
email
'
,
None
)
...
@@ -84,6 +86,9 @@ class Post(APIView):
...
@@ -84,6 +86,9 @@ class Post(APIView):
view_count
=
FeedView
.
objects
.
filter
(
feed_id
=
feed
.
id
,
is_view
=
True
).
count
()
view_count
=
FeedView
.
objects
.
filter
(
feed_id
=
feed
.
id
,
is_view
=
True
).
count
()
feed
.
view_count
=
view_count
feed
.
view_count
=
view_count
is_view
=
FeedView
.
objects
.
filter
(
feed_id
=
feed
.
id
,
is_view
=
True
,
email
=
email
).
exists
()
is_view
=
FeedView
.
objects
.
filter
(
feed_id
=
feed
.
id
,
is_view
=
True
,
email
=
email
).
exists
()
report_count
=
FeedReport
.
objects
.
filter
(
feed_id
=
feed
.
id
,
is_report
=
True
).
count
()
feed
.
report_count
=
report_count
is_report
=
FeedReport
.
objects
.
filter
(
feed_id
=
feed
.
id
,
is_report
=
True
,
email
=
email
).
exists
()
feed
.
save
()
feed
.
save
()
profile_image
=
User
.
objects
.
filter
(
email
=
feed
.
email
).
first
().
thumbnail
or
'
default_profile.jpg
'
profile_image
=
User
.
objects
.
filter
(
email
=
feed
.
email
).
first
().
thumbnail
or
'
default_profile.jpg
'
...
@@ -101,13 +106,14 @@ class Post(APIView):
...
@@ -101,13 +106,14 @@ class Post(APIView):
like_count
=
like_count
,
like_count
=
like_count
,
is_like
=
is_like
,
is_like
=
is_like
,
view_count
=
view_count
,
view_count
=
view_count
,
is_view
=
is_view
is_view
=
is_view
,
report_count
=
report_count
,
is_report
=
is_report
))
))
class
Ranking
(
APIView
):
class
Ranking
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
univ_list
=
Feed
.
objects
.
values
(
'
univ
'
)
\
univ_list
=
Feed
.
objects
.
values
(
'
univ
'
)
\
.
annotate
(
score
=
Count
(
'
univ
'
)
+
Sum
(
'
view_count
'
)
+
Sum
(
'
like_count
'
))
\
.
annotate
(
score
=
Count
(
'
univ
'
)
+
Sum
(
'
view_count
'
)
+
Sum
(
'
like_count
'
))
\
.
order_by
(
'
-score
'
)
.
order_by
(
'
-score
'
)
...
@@ -119,6 +125,7 @@ class Ranking(APIView):
...
@@ -119,6 +125,7 @@ class Ranking(APIView):
'
jinstagram/ranking.html
'
,
'
jinstagram/ranking.html
'
,
context
=
dict
(
univ_list
=
univ_list
))
context
=
dict
(
univ_list
=
univ_list
))
class
Detail
(
APIView
):
class
Detail
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
email
=
request
.
session
.
get
(
'
email
'
,
None
)
email
=
request
.
session
.
get
(
'
email
'
,
None
)
...
@@ -150,6 +157,7 @@ class Detail(APIView):
...
@@ -150,6 +157,7 @@ class Detail(APIView):
context
=
dict
(
feed_list
=
feed_list
,
context
=
dict
(
feed_list
=
feed_list
,
user
=
user
))
user
=
user
))
class
Profile
(
APIView
):
class
Profile
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
email
=
request
.
session
.
get
(
'
email
'
,
None
)
email
=
request
.
session
.
get
(
'
email
'
,
None
)
...
@@ -184,7 +192,6 @@ class Profile(APIView):
...
@@ -184,7 +192,6 @@ class Profile(APIView):
if
len
(
row_feed_list
)
>
0
:
if
len
(
row_feed_list
)
>
0
:
feed_list
.
append
(
dict
(
row_feed_list
=
row_feed_list
))
feed_list
.
append
(
dict
(
row_feed_list
=
row_feed_list
))
return
render
(
request
,
return
render
(
request
,
'
jinstagram/profile.html
'
,
'
jinstagram/profile.html
'
,
context
=
dict
(
feed_list
=
feed_list
,
context
=
dict
(
feed_list
=
feed_list
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment