SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
9f6a9433
Commit
9f6a9433
authored
8 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Replace wildcard imports for explicit ones
parent
0c40602a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
theses/forms.py
+10
-7
10 additions, 7 deletions
theses/forms.py
theses/models.py
+5
-8
5 additions, 8 deletions
theses/models.py
theses/views.py
+12
-15
12 additions, 15 deletions
theses/views.py
with
27 additions
and
30 deletions
theses/forms.py
+
10
−
7
View file @
9f6a9433
from
django
import
forms
from
django
import
forms
from
django.core.mail
import
EmailMessage
from
django.core.mail
import
EmailMessage
from
.models
import
*
# from .models import *
from
.models
import
ThesisLink
from
.helpers
import
past_years
from
.helpers
import
past_years
from
scipost.models
import
Contributor
,
title_dict
class
RequestThesisLinkForm
(
forms
.
ModelForm
):
class
RequestThesisLinkForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
...
@@ -54,8 +57,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
...
@@ -54,8 +57,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
email_text
=
(
'
Dear
'
+
title_dict
[
thesislink
.
requested_by
.
title
]
+
'
'
email_text
=
(
'
Dear
'
+
title_dict
[
thesislink
.
requested_by
.
title
]
+
'
'
+
thesislink
.
requested_by
.
user
.
last_name
+
thesislink
.
requested_by
.
user
.
last_name
+
'
,
\n\n
The Thesis Link you have requested, concerning thesis with
title
'
+
'
,
\n\n
The Thesis Link you have requested, concerning thesis with
'
+
thesislink
.
title
+
'
by
'
+
thesislink
.
author
+
'
title
'
+
thesislink
.
title
+
'
by
'
+
thesislink
.
author
+
'
, has been activated at https://scipost.org/thesis/
'
+
'
, has been activated at https://scipost.org/thesis/
'
+
str
(
thesislink
.
id
)
+
'
.
'
+
str
(
thesislink
.
id
)
+
'
.
'
+
'
\n\n
Thank you for your contribution,
\n
The SciPost Team.
'
)
+
'
\n\n
Thank you for your contribution,
\n
The SciPost Team.
'
)
...
@@ -68,8 +71,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
...
@@ -68,8 +71,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
elif
int
(
self
.
cleaned_data
[
'
action_option
'
])
==
VetThesisLinkForm
.
REFUSE
:
elif
int
(
self
.
cleaned_data
[
'
action_option
'
])
==
VetThesisLinkForm
.
REFUSE
:
email_text
=
(
'
Dear
'
+
title_dict
[
thesislink
.
requested_by
.
title
]
+
'
'
email_text
=
(
'
Dear
'
+
title_dict
[
thesislink
.
requested_by
.
title
]
+
'
'
+
thesislink
.
requested_by
.
user
.
last_name
+
thesislink
.
requested_by
.
user
.
last_name
+
'
,
\n\n
The Thesis Link you have requested, concerning thesis with
title
'
+
'
,
\n\n
The Thesis Link you have requested, concerning thesis with
'
+
thesislink
.
title
+
'
by
'
+
thesislink
.
author
+
'
title
'
+
thesislink
.
title
+
'
by
'
+
thesislink
.
author
+
'
, has not been activated for the following reason:
'
+
'
, has not been activated for the following reason:
'
+
self
.
cleaned_data
[
'
refusal_reason
'
]
+
self
.
cleaned_data
[
'
refusal_reason
'
]
+
'
.
\n\n
Thank you for your interest,
\n
The SciPost Team.
'
)
+
'
.
\n\n
Thank you for your interest,
\n
The SciPost Team.
'
)
...
@@ -90,8 +93,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
...
@@ -90,8 +93,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
thesislink
.
save
()
thesislink
.
save
()
email_text
=
(
'
Dear
'
+
title_dict
[
thesislink
.
requested_by
.
title
]
+
'
'
email_text
=
(
'
Dear
'
+
title_dict
[
thesislink
.
requested_by
.
title
]
+
'
'
+
thesislink
.
requested_by
.
user
.
last_name
+
thesislink
.
requested_by
.
user
.
last_name
+
'
,
\n\n
The Thesis Link you have requested, concerning thesis with
title
'
+
'
,
\n\n
The Thesis Link you have requested, concerning thesis with
'
+
thesislink
.
title
+
'
by
'
+
thesislink
.
author_list
+
'
title
'
+
thesislink
.
title
+
'
by
'
+
thesislink
.
author_list
+
'
, has been activated
'
+
'
, has been activated
'
'
(with slight modifications to your submitted details) at
'
'
(with slight modifications to your submitted details) at
'
'
https://scipost.org/thesis/
'
+
str
(
thesislink
.
id
)
+
'
.
'
'
https://scipost.org/thesis/
'
+
str
(
thesislink
.
id
)
+
'
.
'
...
...
This diff is collapsed.
Click to expand it.
theses/models.py
+
5
−
8
View file @
9f6a9433
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.db
import
models
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
django.template
import
Template
,
Context
from
django.template
import
Template
,
Context
from
.models
import
*
from
journals.models
import
SCIPOST_JOURNALS_DOMAINS
,
journals_domains_dict
from
scipost.constants
import
SCIPOST_DISCIPLINES
,
SCIPOST_SUBJECT_AREAS
,
\
from
journals.models
import
*
subject_areas_dict
,
disciplines_dict
from
scipost.constants
import
SCIPOST_DISCIPLINES
,
subject_areas_dict
,
disciplines_dict
from
scipost.models
import
Contributor
from
scipost.models
import
*
class
ThesisLink
(
models
.
Model
):
class
ThesisLink
(
models
.
Model
):
...
@@ -75,8 +73,7 @@ class ThesisLink(models.Model):
...
@@ -75,8 +73,7 @@ class ThesisLink(models.Model):
'
pub_link
'
:
self
.
pub_link
,
'
institution
'
:
self
.
institution
,
'
pub_link
'
:
self
.
pub_link
,
'
institution
'
:
self
.
institution
,
'
supervisor
'
:
self
.
supervisor
,
'
defense_date
'
:
self
.
defense_date
,
'
supervisor
'
:
self
.
supervisor
,
'
defense_date
'
:
self
.
defense_date
,
'
latest_activity
'
:
self
.
latest_activity
.
strftime
(
'
%Y-%m-%d %H:%M
'
)})
'
latest_activity
'
:
self
.
latest_activity
.
strftime
(
'
%Y-%m-%d %H:%M
'
)})
print
(
subject_areas_dict
)
print
(
self
.
subject_area
in
subject_areas_dict
)
header
=
(
header
=
(
'
<li><div class=
"
flex-container
"
>
'
'
<li><div class=
"
flex-container
"
>
'
'
<div class=
"
flex-whitebox0
"
><p><a href=
"
/thesis/{{ id }}
"
'
'
<div class=
"
flex-whitebox0
"
><p><a href=
"
/thesis/{{ id }}
"
'
...
...
This diff is collapsed.
Click to expand it.
theses/views.py
+
12
−
15
View file @
9f6a9433
...
@@ -2,25 +2,21 @@ import datetime
...
@@ -2,25 +2,21 @@ import datetime
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.shortcuts
import
get_object_or_404
,
render
from
django.shortcuts
import
get_object_or_404
,
render
from
django.contrib.auth
import
authenticate
,
login
,
logout
from
django.contrib.auth.decorators
import
permission_required
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.contrib.auth.models
import
User
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.core.mail
import
EmailMessage
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.http
import
HttpResponse
,
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
from
django.views.decorators.csrf
import
csrf_protect
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.db.models
import
Avg
from
django.views.generic.edit
import
CreateView
,
FormView
,
UpdateView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.utils.decorators
import
method_decorator
from
django.utils.decorators
import
method_decorator
from
.models
import
*
from
.models
import
ThesisLink
from
.forms
import
*
from
.forms
import
RequestThesisLinkForm
,
ThesisLinkSearchForm
,
VetThesisLinkForm
from
comments.models
import
Comment
from
comments.models
import
Comment
from
comments.forms
import
CommentForm
from
comments.forms
import
CommentForm
from
scipost.forms
import
TITLE_CHOICES
,
AuthenticationForm
from
scipost.forms
import
TITLE_CHOICES
from
scipost.models
import
Contributor
import
strings
import
strings
title_dict
=
dict
(
TITLE_CHOICES
)
# Convert titles for use in emails
title_dict
=
dict
(
TITLE_CHOICES
)
# Convert titles for use in emails
...
@@ -64,9 +60,9 @@ class VetThesisLink(UpdateView):
...
@@ -64,9 +60,9 @@ class VetThesisLink(UpdateView):
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
# I totally override the form_valid method. I do not call super.
# I totally override the form_valid method. I do not call super.
# This is because, by default, an UpdateView saves the object as instance,
# This is because, by default, an UpdateView saves the object as instance,
# which it builds from the form data. So, the changes (by whom the thesis link was
vetted, etc.)
# which it builds from the form data. So, the changes (by whom the thesis link was
# would be lost. Instead, we need the form to save with commit=False,
then modify
#
vetted, etc.)
would be lost. Instead, we need the form to save with commit=False,
# the vetting fields, and then save.
#
then modify
the vetting fields, and then save.
# Builds model that reflects changes made during update. Does not yet save.
# Builds model that reflects changes made during update. Does not yet save.
self
.
object
=
form
.
save
(
commit
=
False
)
self
.
object
=
form
.
save
(
commit
=
False
)
...
@@ -102,7 +98,8 @@ def theses(request):
...
@@ -102,7 +98,8 @@ def theses(request):
thesislink_recent_list
=
(
ThesisLink
.
objects
thesislink_recent_list
=
(
ThesisLink
.
objects
.
filter
(
vetted
=
True
,
.
filter
(
vetted
=
True
,
latest_activity__gte
=
timezone
.
now
()
+
datetime
.
timedelta
(
days
=-
7
)))
latest_activity__gte
=
timezone
.
now
()
+
datetime
.
timedelta
(
days
=-
7
)))
context
=
{
'
form
'
:
form
,
'
thesislink_search_list
'
:
thesislink_search_list
,
context
=
{
'
form
'
:
form
,
'
thesislink_search_list
'
:
thesislink_search_list
,
'
thesislink_recent_list
'
:
thesislink_recent_list
}
'
thesislink_recent_list
'
:
thesislink_recent_list
}
return
render
(
request
,
'
theses/theses.html
'
,
context
)
return
render
(
request
,
'
theses/theses.html
'
,
context
)
...
...
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