From 153fc38890812776f47bd31228bb219473813a15 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Sun, 18 Jun 2017 20:21:47 +0200 Subject: [PATCH] Improve various scipost-app code --- scipost/managers.py | 12 +++++++++++- scipost/models.py | 9 +++++++-- scipost/services.py | 6 ------ scipost/static/scipost/assets/css/_type.scss | 1 + scipost/templatetags/scipost_extras.py | 4 ++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/scipost/managers.py b/scipost/managers.py index 518ca5aaf..2276fc60f 100644 --- a/scipost/managers.py +++ b/scipost/managers.py @@ -3,7 +3,7 @@ import datetime from django.db import models from django.db.models import Q -from .constants import CONTRIBUTOR_NORMAL +from .constants import CONTRIBUTOR_NORMAL, INVITATION_EDITORIAL_FELLOW class FellowManager(models.Manager): @@ -20,3 +20,13 @@ class FellowManager(models.Manager): class ContributorManager(models.Manager): def active(self): return self.filter(user__is_active=True, status=CONTRIBUTOR_NORMAL) + + +class RegistrationInvitationManager(models.Manager): + def pending_invited_fellows(self): + return self.filter(invitation_type=INVITATION_EDITORIAL_FELLOW, + responded=False, declined=False) + + def declined_invited_fellows(self): + return self.filter(invitation_type=INVITATION_EDITORIAL_FELLOW, + responded=False, declined=True) diff --git a/scipost/models.py b/scipost/models.py index d8a4d015c..1e1ad810c 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -19,7 +19,7 @@ from .constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS,\ INVITATION_CONTRIBUTOR, INVITATION_FORMAL,\ AUTHORSHIP_CLAIM_PENDING, AUTHORSHIP_CLAIM_STATUS from .fields import ChoiceArrayField -from .managers import FellowManager, ContributorManager +from .managers import FellowManager, ContributorManager, RegistrationInvitationManager def get_sentinel_user(): @@ -184,7 +184,7 @@ class Remark(models.Model): recommendation = models.ForeignKey('submissions.EICRecommendation', on_delete=models.CASCADE, blank=True, null=True) - date = models.DateTimeField() + date = models.DateTimeField(auto_now_add=True) remark = models.TextField() def __str__(self): @@ -261,6 +261,11 @@ class RegistrationInvitation(models.Model): responded = models.BooleanField(default=False) declined = models.BooleanField(default=False) + objects = RegistrationInvitationManager() + + class Meta: + ordering = ['last_name'] + def __str__(self): return (self.first_name + ' ' + self.last_name + ' on ' + self.date_sent.strftime("%Y-%m-%d")) diff --git a/scipost/services.py b/scipost/services.py index 7a6707e8f..9e61ccd73 100644 --- a/scipost/services.py +++ b/scipost/services.py @@ -1,15 +1,9 @@ # Module for making external api calls as needed in the submissions cycle import feedparser import requests -import re import datetime import dateutil.parser -from django.template import Template, Context -from .behaviors import ArxivCallable - -from strings import arxiv_caller_errormessages - class DOICaller: def __init__(self, doi_string): diff --git a/scipost/static/scipost/assets/css/_type.scss b/scipost/static/scipost/assets/css/_type.scss index 4a6abda1d..47d2ee08d 100644 --- a/scipost/static/scipost/assets/css/_type.scss +++ b/scipost/static/scipost/assets/css/_type.scss @@ -92,6 +92,7 @@ hr.hr12 { margin-bottom: 1rem; border-radius: 99px; box-shadow: 0 1px 0 0 #d3e3f6; + width: 100%; &.small { height: 1px; diff --git a/scipost/templatetags/scipost_extras.py b/scipost/templatetags/scipost_extras.py index 9d9861514..25c81e2b0 100644 --- a/scipost/templatetags/scipost_extras.py +++ b/scipost/templatetags/scipost_extras.py @@ -1,7 +1,6 @@ from django import template -from django.contrib.auth.models import Group -from ..constants import subject_areas_dict +from ..constants import subject_areas_dict, subject_areas_raw_dict from ..models import Contributor register = template.Library() @@ -15,6 +14,7 @@ register = template.Library() def sort_by(queryset, order): return queryset.order_by(order) + @register.filter(name='duration') def duration(dur): total_seconds = int(dur.total_seconds()) -- GitLab