Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
bf8001dc
Commit
bf8001dc
authored
Feb 11, 2016
by
Mathieu Rodic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] started working on the `/projects/(\d+)` page
[CODE] more cleaning (espacially in the views)
parent
d6aa1e6e
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
624 additions
and
77 deletions
+624
-77
users.py
gargantext/models/users.py
+3
-2
http.py
gargantext/util/http.py
+0
-1
auth.py
gargantext/views/pages/auth.py
+27
-32
main.py
gargantext/views/pages/main.py
+32
-36
projects.py
gargantext/views/pages/projects.py
+18
-0
urls.py
gargantext/views/pages/urls.py
+1
-0
menu.html
templates/pages/menu.html
+2
-2
overview.html
templates/pages/projects/overview.html
+4
-4
project.html
templates/pages/projects/project.html
+537
-0
No files found.
gargantext/models/users.py
View file @
bf8001dc
...
...
@@ -34,6 +34,7 @@ class User(Base):
def
get_nodes
(
self
,
nodetype
=
None
):
"""get all nodes belonging to the user"""
# ↓ this below is a workaround because of Python's lame import system
from
.nodes
import
Node
query
=
(
session
.
query
(
Node
)
...
...
@@ -54,7 +55,7 @@ class Contact(Base):
id
=
Column
(
Integer
,
primary_key
=
True
)
user1_id
=
Column
(
Integer
,
primary_key
=
True
)
user2_id
=
Column
(
Integer
,
primary_key
=
True
)
is_blocked
=
Column
(
Boolean
())
date_creation
=
DateTime
(
timezone
=
False
)
is_blocked
=
Column
(
Boolean
()
,
default
=
False
)
date_creation
=
Column
(
DateTime
(
timezone
=
False
)
)
__table_args__
=
(
UniqueConstraint
(
'user1_id'
,
'user2_id'
),
)
gargantext/util/http.py
View file @
bf8001dc
from
django.template.loader
import
get_template
from
django.template
import
Context
,
RequestContext
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
,
HttpResponseForbidden
from
django.shortcuts
import
render
,
redirect
...
...
gargantext/views/pages/auth.py
View file @
bf8001dc
...
...
@@ -4,45 +4,40 @@ from django.contrib import auth
def
login
(
request
):
logout
(
request
)
username
=
password
=
''
next_page
=
""
if
request
.
method
==
"GET"
:
"""Performs user login
"""
auth
.
logout
(
request
)
# if the user wants to access the login form
if
request
.
method
==
'GET'
:
additional_context
=
{}
# if for exemple: auth/?next=/project/5/corpus/554/document/556/
# => we'll forward ?next="..." into template with form
if
(
'next'
in
request
.
GET
)
:
if
'next'
in
request
.
GET
:
additional_context
=
{
'next_page'
:
request
.
GET
[
'next'
]}
return
render_to_response
(
'pages/auth/login.html'
,
additional_context
,
context_instance
=
RequestContext
(
request
)
)
return
render
(
template_name
=
'pages/auth/login.html'
,
request
=
request
,
context
=
additional_context
,
)
# if the user send her authentication data to the page
elif
request
.
method
==
"POST"
:
username
=
request
.
POST
[
'username'
]
# /!\ pass is sent clear in POST data
password
=
request
.
POST
[
'password'
]
user
=
auth
.
authenticate
(
username
=
username
,
password
=
password
)
if
user
is
not
None
:
if
user
.
is_active
:
auth
.
login
(
request
,
user
)
# if "next" forwarded from the GET via the template form
if
(
'the_next_page'
in
request
.
POST
):
return
HttpResponseRedirect
(
request
.
POST
[
'the_next_page'
])
else
:
return
HttpResponseRedirect
(
'/projects/'
)
# /!\ pass is sent clear in POST data: use SSL
user
=
auth
.
authenticate
(
username
=
request
.
POST
[
'username'
],
password
=
request
.
POST
[
'password'
]
)
if
user
is
not
None
and
user
.
is_active
:
auth
.
login
(
request
,
user
)
# if "next" forwarded from the GET via the template form
if
'the_next_page'
in
request
.
POST
:
return
redirect
(
request
.
POST
[
'the_next_page'
])
else
:
return
redirect
(
'/projects/'
)
def
logout
(
request
):
'''
Logout the user, and redirect to main page
'''
"""
Logout the user, and redirect to main page
"""
auth
.
logout
(
request
)
return
HttpResponseR
edirect
(
'/'
)
return
r
edirect
(
'/'
)
gargantext/views/pages/main.py
View file @
bf8001dc
...
...
@@ -9,49 +9,45 @@ def home(request):
A video draws the narratives.
If not logged a project test is shown.
'''
template
=
get_template
(
'pages/main/home.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
html
=
t
.
render
(
Context
(
{
'debug'
:
settings
.
DEBUG
,
'user'
:
user
,
'date'
:
date
,
'paragraph_gargantua'
:
paragraphs
.
gargantua
(),
'paragraph_lorem'
:
paragraphs
.
lorem
(),
'paragraph_tutoreil'
:
paragraphs
.
tutoreil
(),
}))
return
HttpResponse
(
html
)
return
render
(
template_name
=
'pages/main/home.html'
,
request
=
request
,
context
=
{
'debug'
:
settings
.
DEBUG
,
'user'
:
request
.
user
,
'date'
:
datetime
.
datetime
.
now
()
,
'paragraph_gargantua'
:
paragraphs
.
gargantua
(),
'paragraph_lorem'
:
paragraphs
.
lorem
(),
'paragraph_tutoreil'
:
paragraphs
.
tutoreil
(),
},
)
def
about
(
request
):
'''About Gargantext, its team and sponsors
'''
template
=
get_template
(
'pages/main/about.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
html
=
template
.
render
(
Context
({
'user'
:
user
,
'date'
:
date
,
'team'
:
credits
.
members
(),
'institutions'
:
credits
.
institutions
(),
'labos'
:
credits
.
labs
(),
'grants'
:
credits
.
grants
(),
}))
return
HttpResponse
(
html
)
return
render
(
template_name
=
'pages/main/about.html'
,
request
=
request
,
context
=
{
'user'
:
request
.
user
,
'date'
:
datetime
.
datetime
.
now
(),
'team'
:
credits
.
members
(),
'institutions'
:
credits
.
institutions
(),
'labos'
:
credits
.
labs
(),
'grants'
:
credits
.
grants
(),
},
)
def
maintenance
(
request
):
'''Gargantext out of service
'''
template
=
get_template
(
'pages/main/maintenance.html'
)
user
=
request
.
user
date
=
datetime
.
datetime
.
now
()
html
=
template
.
render
(
Context
({
\
'user'
:
user
,
\
'date'
:
date
,
\
}))
return
HttpResponse
(
html
)
return
render
(
template_name
=
'pages/main/maintenance.html'
,
request
=
request
,
context
=
{
'user'
:
request
.
user
,
'date'
:
datetime
.
datetime
.
now
(),
},
)
gargantext/views/pages/projects.py
View file @
bf8001dc
...
...
@@ -58,3 +58,21 @@ def overview(request):
'common_projects'
:
contacts_projects
if
len
(
contacts_projects
)
else
False
,
},
)
@
requires_auth
def
project
(
request
,
project_id
):
return
render
(
template_name
=
'pages/projects/project.html'
,
request
=
request
,
context
=
{
# 'debug': settings.DEBUG,
# 'date': datetime.now(),
# # projects owned by the user
# 'number': len(user_projects),
# 'projects': user_projects,
# # projects owned by the user's contacts
# 'common_users': contacts if len(contacts) else False,
# 'common_projects': contacts_projects if len(contacts_projects) else False,
},
)
gargantext/views/pages/urls.py
View file @
bf8001dc
...
...
@@ -16,5 +16,6 @@ urlpatterns = [
# overview on projects
url
(
r'^projects/?$'
,
projects
.
overview
),
url
(
r'^projects/(\d+)/?$'
,
projects
.
project
),
]
templates/pages/menu.html
View file @
bf8001dc
...
...
@@ -27,10 +27,10 @@
<li><a
href=
"/projects/"
title=
"All your projects are here."
>
Projects
</a></li>
{% endif %}
{% if project %}
<li><a
href=
"/project/{{project.id}}"
>
{{project.name}}
</a></li>
<li><a
href=
"/project
s
/{{project.id}}"
>
{{project.name}}
</a></li>
{% endif %}
{% if corpus %}
<li><a
href=
"/project
/{{project.id}}/corpus
/{{corpus.id}}"
>
{{corpus.name}}
</a></li>
<li><a
href=
"/project
s/{{project.id}}/corpora
/{{corpus.id}}"
>
{{corpus.name}}
</a></li>
{% endif %}
</ul>
...
...
templates/pages/projects/overview.html
View file @
bf8001dc
...
...
@@ -46,13 +46,13 @@
{% for project in projects %}
<!--<div class="col-md-offset-7 col-md-4 content" style="background-color:grey">!-->
<div
class=
"col-md-3 content"
>
<h3><a
href=
"/project/{{ project.id }}"
>
{{ project.name }}
</a>
<h3><a
href=
"/project
s
/{{ project.id }}"
>
{{ project.name }}
</a>
<button
type=
"button"
class=
"btn btn-xs btn-default"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
'
<ul>
<li> Rename </li>
<li><a href="/project/{{ project.id }}">Add new corpus</a></li>
<li><a href="/project
s
/{{ project.id }}">Add new corpus</a></li>
<li><a href="/delete/{{ project.id }}">Delete</a></li>
</ul>
'
>
Manage
</button>
...
...
@@ -73,12 +73,12 @@
{% for project in common_projects %}
<!--<div class="col-md-offset-7 col-md-4 content" style="background-color:grey">!-->
<div
class=
"col-md-3 content"
>
<h3><a
href=
"/project/{{ project.id }}"
>
{{ project.name }}
</a>
<h3><a
href=
"/project
s
/{{ project.id }}"
>
{{ project.name }}
</a>
<button
type=
"button"
class=
"btn btn-xs btn-default"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
'
<ul>
<li> Rename </li>
<li><a href="/project/{{ project.id }}">Add new corpus</a></li>
<li><a href="/project
s
/{{ project.id }}">Add new corpus</a></li>
<li><a href="/delete/{{ project.id }}">Delete</a></li>
</ul>
'
>
Manage
</button>
...
...
templates/pages/projects/project.html
0 → 100644
View file @
bf8001dc
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment