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
90dd952b
Commit
90dd952b
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
0f8fc1ea
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 @
90dd952b
...
@@ -34,6 +34,7 @@ class User(Base):
...
@@ -34,6 +34,7 @@ class User(Base):
def
get_nodes
(
self
,
nodetype
=
None
):
def
get_nodes
(
self
,
nodetype
=
None
):
"""get all nodes belonging to the user"""
"""get all nodes belonging to the user"""
# ↓ this below is a workaround because of Python's lame import system
from
.nodes
import
Node
from
.nodes
import
Node
query
=
(
session
query
=
(
session
.
query
(
Node
)
.
query
(
Node
)
...
@@ -54,7 +55,7 @@ class Contact(Base):
...
@@ -54,7 +55,7 @@ class Contact(Base):
id
=
Column
(
Integer
,
primary_key
=
True
)
id
=
Column
(
Integer
,
primary_key
=
True
)
user1_id
=
Column
(
Integer
,
primary_key
=
True
)
user1_id
=
Column
(
Integer
,
primary_key
=
True
)
user2_id
=
Column
(
Integer
,
primary_key
=
True
)
user2_id
=
Column
(
Integer
,
primary_key
=
True
)
is_blocked
=
Column
(
Boolean
())
is_blocked
=
Column
(
Boolean
()
,
default
=
False
)
date_creation
=
DateTime
(
timezone
=
False
)
date_creation
=
Column
(
DateTime
(
timezone
=
False
)
)
__table_args__
=
(
UniqueConstraint
(
'user1_id'
,
'user2_id'
),
)
__table_args__
=
(
UniqueConstraint
(
'user1_id'
,
'user2_id'
),
)
gargantext/util/http.py
View file @
90dd952b
from
django.template.loader
import
get_template
from
django.template.loader
import
get_template
from
django.template
import
Context
,
RequestContext
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
,
HttpResponseForbidden
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseRedirect
,
HttpResponseForbidden
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
...
...
gargantext/views/pages/auth.py
View file @
90dd952b
...
@@ -4,45 +4,40 @@ from django.contrib import auth
...
@@ -4,45 +4,40 @@ from django.contrib import auth
def
login
(
request
):
def
login
(
request
):
"""Performs user login
logout
(
request
)
"""
username
=
password
=
''
auth
.
logout
(
request
)
# if the user wants to access the login form
next_page
=
""
if
request
.
method
==
'GET'
:
if
request
.
method
==
"GET"
:
additional_context
=
{}
additional_context
=
{}
# if for exemple: auth/?next=/project/5/corpus/554/document/556/
# if for exemple: auth/?next=/project/5/corpus/554/document/556/
# => we'll forward ?next="..." into template with form
# => 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'
]}
additional_context
=
{
'next_page'
:
request
.
GET
[
'next'
]}
return
render_to_response
(
'pages/auth/login.html'
,
return
render
(
additional_context
,
template_name
=
'pages/auth/login.html'
,
context_instance
=
RequestContext
(
request
)
request
=
request
,
)
context
=
additional_context
,
)
# if the user send her authentication data to the page
elif
request
.
method
==
"POST"
:
elif
request
.
method
==
"POST"
:
username
=
request
.
POST
[
'username'
]
# /!\ pass is sent clear in POST data: use SSL
user
=
auth
.
authenticate
(
# /!\ pass is sent clear in POST data
username
=
request
.
POST
[
'username'
],
password
=
request
.
POST
[
'password'
]
password
=
request
.
POST
[
'password'
]
)
user
=
auth
.
authenticate
(
username
=
username
,
password
=
password
)
if
user
is
not
None
and
user
.
is_active
:
if
user
is
not
None
:
auth
.
login
(
request
,
user
)
# if "next" forwarded from the GET via the template form
if
user
.
is_active
:
if
'the_next_page'
in
request
.
POST
:
auth
.
login
(
request
,
user
)
return
redirect
(
request
.
POST
[
'the_next_page'
])
else
:
# if "next" forwarded from the GET via the template form
return
redirect
(
'/projects/'
)
if
(
'the_next_page'
in
request
.
POST
):
return
HttpResponseRedirect
(
request
.
POST
[
'the_next_page'
])
else
:
return
HttpResponseRedirect
(
'/projects/'
)
def
logout
(
request
):
def
logout
(
request
):
'''
Logout the user, and redirect to main page
"""
Logout the user, and redirect to main page
'''
"""
auth
.
logout
(
request
)
auth
.
logout
(
request
)
return
HttpResponseR
edirect
(
'/'
)
return
r
edirect
(
'/'
)
gargantext/views/pages/main.py
View file @
90dd952b
...
@@ -9,49 +9,45 @@ def home(request):
...
@@ -9,49 +9,45 @@ def home(request):
A video draws the narratives.
A video draws the narratives.
If not logged a project test is shown.
If not logged a project test is shown.
'''
'''
template
=
get_template
(
'pages/main/home.html'
)
return
render
(
user
=
request
.
user
template_name
=
'pages/main/home.html'
,
date
=
datetime
.
datetime
.
now
()
request
=
request
,
html
=
t
.
render
(
Context
(
{
context
=
{
'debug'
:
settings
.
DEBUG
,
'debug'
:
settings
.
DEBUG
,
'user'
:
user
,
'user'
:
request
.
user
,
'date'
:
date
,
'date'
:
datetime
.
datetime
.
now
()
,
'paragraph_gargantua'
:
paragraphs
.
gargantua
(),
'paragraph_gargantua'
:
paragraphs
.
gargantua
(),
'paragraph_lorem'
:
paragraphs
.
lorem
(),
'paragraph_lorem'
:
paragraphs
.
lorem
(),
'paragraph_tutoreil'
:
paragraphs
.
tutoreil
(),
'paragraph_tutoreil'
:
paragraphs
.
tutoreil
(),
}))
},
return
HttpResponse
(
html
)
)
def
about
(
request
):
def
about
(
request
):
'''About Gargantext, its team and sponsors
'''About Gargantext, its team and sponsors
'''
'''
template
=
get_template
(
'pages/main/about.html'
)
return
render
(
user
=
request
.
user
template_name
=
'pages/main/about.html'
,
date
=
datetime
.
datetime
.
now
()
request
=
request
,
context
=
{
html
=
template
.
render
(
Context
({
'user'
:
request
.
user
,
'user'
:
user
,
'date'
:
datetime
.
datetime
.
now
(),
'date'
:
date
,
'team'
:
credits
.
members
(),
'team'
:
credits
.
members
(),
'institutions'
:
credits
.
institutions
(),
'institutions'
:
credits
.
institutions
(),
'labos'
:
credits
.
labs
(),
'labos'
:
credits
.
labs
(),
'grants'
:
credits
.
grants
(),
'grants'
:
credits
.
grants
(),
},
}))
)
return
HttpResponse
(
html
)
def
maintenance
(
request
):
def
maintenance
(
request
):
'''Gargantext out of service
'''Gargantext out of service
'''
'''
template
=
get_template
(
'pages/main/maintenance.html'
)
return
render
(
user
=
request
.
user
template_name
=
'pages/main/maintenance.html'
,
date
=
datetime
.
datetime
.
now
()
request
=
request
,
context
=
{
html
=
template
.
render
(
Context
({
\
'user'
:
request
.
user
,
'user'
:
user
,
\
'date'
:
datetime
.
datetime
.
now
(),
'date'
:
date
,
\
},
}))
)
return
HttpResponse
(
html
)
gargantext/views/pages/projects.py
View file @
90dd952b
...
@@ -58,3 +58,21 @@ def overview(request):
...
@@ -58,3 +58,21 @@ def overview(request):
'common_projects'
:
contacts_projects
if
len
(
contacts_projects
)
else
False
,
'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 @
90dd952b
...
@@ -16,5 +16,6 @@ urlpatterns = [
...
@@ -16,5 +16,6 @@ urlpatterns = [
# overview on projects
# overview on projects
url
(
r'^projects/?$'
,
projects
.
overview
),
url
(
r'^projects/?$'
,
projects
.
overview
),
url
(
r'^projects/(\d+)/?$'
,
projects
.
project
),
]
]
templates/pages/menu.html
View file @
90dd952b
...
@@ -27,10 +27,10 @@
...
@@ -27,10 +27,10 @@
<li><a
href=
"/projects/"
title=
"All your projects are here."
>
Projects
</a></li>
<li><a
href=
"/projects/"
title=
"All your projects are here."
>
Projects
</a></li>
{% endif %}
{% endif %}
{% if project %}
{% if project %}
<li><a
href=
"/project/{{project.id}}"
>
{{project.name}}
</a></li>
<li><a
href=
"/project
s
/{{project.id}}"
>
{{project.name}}
</a></li>
{% endif %}
{% endif %}
{% if corpus %}
{% 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 %}
{% endif %}
</ul>
</ul>
...
...
templates/pages/projects/overview.html
View file @
90dd952b
...
@@ -46,13 +46,13 @@
...
@@ -46,13 +46,13 @@
{% for project in projects %}
{% for project in projects %}
<!--<div class="col-md-offset-7 col-md-4 content" style="background-color:grey">!-->
<!--<div class="col-md-offset-7 col-md-4 content" style="background-color:grey">!-->
<div
class=
"col-md-3 content"
>
<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"
<button
type=
"button"
class=
"btn btn-xs btn-default"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
'
data-content=
'
<ul>
<ul>
<li> Rename </li>
<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>
<li><a href="/delete/{{ project.id }}">Delete</a></li>
</ul>
</ul>
'
>
Manage
</button>
'
>
Manage
</button>
...
@@ -73,12 +73,12 @@
...
@@ -73,12 +73,12 @@
{% for project in common_projects %}
{% for project in common_projects %}
<!--<div class="col-md-offset-7 col-md-4 content" style="background-color:grey">!-->
<!--<div class="col-md-offset-7 col-md-4 content" style="background-color:grey">!-->
<div
class=
"col-md-3 content"
>
<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"
<button
type=
"button"
class=
"btn btn-xs btn-default"
data-container=
"body"
data-toggle=
"popover"
data-placement=
"bottom"
data-content=
'
data-content=
'
<ul>
<ul>
<li> Rename </li>
<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>
<li><a href="/delete/{{ project.id }}">Delete</a></li>
</ul>
</ul>
'
>
Manage
</button>
'
>
Manage
</button>
...
...
templates/pages/projects/project.html
0 → 100644
View file @
90dd952b
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