Skip to content

Commit

Permalink
Merge branch 'main' into task/DES-2562--myworkingfiles-listing
Browse files Browse the repository at this point in the history
  • Loading branch information
rstijerina authored Aug 22, 2023
2 parents b09c247 + 1a809bb commit c0b9c28
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 18 deletions.
23 changes: 12 additions & 11 deletions conf/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
FROM node:16 as node_build
COPY package.json package-lock.json /designsafe/
WORKDIR /designsafe
RUN npm ci

COPY . /designsafe/
RUN npm run build


FROM python:3.7-buster

LABEL MAINTAINER="DesignSafe-CI <[email protected]>"
Expand Down Expand Up @@ -27,10 +36,6 @@ RUN apt-get update && apt-get install -y \
git \
vim

# install node 16.x
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs

RUN pip install poetry
COPY poetry.lock pyproject.toml /srv/www/
WORKDIR /srv/www
Expand All @@ -41,14 +46,10 @@ RUN poetry config virtualenvs.create false && \
RUN groupadd --gid 816877 G-816877 && \
useradd --uid 458981 --gid G-816877 -m --shell /bin/bash tg458981 -d /home/tg458981

COPY . /srv/www/designsafe
RUN chown -R tg458981:G-816877 /srv/www/designsafe
COPY --from=node_build /designsafe/ /srv/www/designsafe
RUN chown tg458981:G-816877 /srv/www/designsafe /srv/www/designsafe/*
RUN chown -R tg458981:G-816877 /srv/www/designsafe/designsafe

USER tg458981

RUN echo "prefix=~/.npm-global" >> ~/.npmrc

WORKDIR /srv/www/designsafe

RUN npm ci
RUN npm run build
5 changes: 5 additions & 0 deletions designsafe/apps/api/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def get(self, request):
if role:
logger.info(role)
user_rs = user_rs.filter(groups__name=role)

# Prevent endpoint from returning unfiltered user list.
if not q and not role:
return HttpResponseNotFound()

resp = [model_to_dict(u, fields=resp_fields) for u in user_rs]
if len(resp):
return JsonResponse(resp, safe=False)
Expand Down
3 changes: 3 additions & 0 deletions designsafe/apps/notifications/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.contrib import admin
from designsafe.apps.notifications.models import SiteMessage

# Register your models here.

admin.site.register(SiteMessage)
23 changes: 23 additions & 0 deletions designsafe/apps/notifications/migrations/0003_sitemessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2023-08-04 15:55
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('notifications', '0002_auto_20160301_2331'),
]

operations = [
migrations.CreateModel(
name='SiteMessage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('message', models.TextField(help_text='Text for the alert message')),
('display', models.BooleanField()),
],
),
]
7 changes: 7 additions & 0 deletions designsafe/apps/notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ def receive_notification(sender, **kwargs):
notification.save()

Event.send_event(event_type, event_users, event_data)


#pylint: enable=invalid-name
class SiteMessage(models.Model):
"""Warning message to display on all pages."""
message = models.TextField(help_text='Text for the alert message')
display = models.BooleanField()
8 changes: 8 additions & 0 deletions designsafe/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
is_path_protected)
from termsandconditions.models import TermsAndConditions
from django.shortcuts import redirect, reverse
from designsafe.apps.notifications.models import SiteMessage

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,6 +62,13 @@ def process_request(self, request):
'Use is required for continued use of DesignSafe '
'resources.' % accept_url)
return None


class SiteMessageMiddleware:
def process_request(self, request):
for message in SiteMessage.objects.filter(display=True):
messages.warning(request, message.message)


class RequestProfilingMiddleware(object):
"""Middleware to run cProfiler on each request"""
Expand Down
2 changes: 2 additions & 0 deletions designsafe/settings/common_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

# SESSIONS
SESSION_COOKIE_DOMAIN = os.environ.get('SESSION_COOKIE_DOMAIN')
SESSION_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# SECURITY WARNING: don't run with debug turned on in production!
Expand Down Expand Up @@ -143,6 +144,7 @@
'impersonate.middleware.ImpersonateMiddleware',
'designsafe.middleware.DesignSafeTermsMiddleware',
'designsafe.middleware.DesignsafeProfileUpdateMiddleware',
'designsafe.middleware.SiteMessageMiddleware',
)

ROOT_URLCONF = 'designsafe.urls'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class NeesDoiListCtrl {

$onInit() {
this.project = this.resolve.project;
this.experimentDois = this.project.metadata.experiments.map((exp)=> {
this.experimentDois = this.project.metadata.experiments.filter(exp => !!exp.doi).map((exp)=> {
const authors = (exp.creators ? exp.creators.map((author) => `${author.lastName}, ${author.firstName}`).join('; ') : '')
const year = exp.endDate.split('T')[0].split('-')[0];
const doi = exp.doi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ <h3 class="text-center">
</span>
</div>
<div class="entity-meta-field">
<div class="entity-meta-label-multi" ng-if="(!$ctrl.readOnly && mission.value.dois.toString() === '') || $ctrl.readOnly">License(s)</div>
<div class="entity-meta-label-multi" ng-if="(!$ctrl.readOnly && hybsim.value.dois.toString() === '') || $ctrl.readOnly">License(s)</div>
<div class="entity-meta-data" ng-if="!$ctrl.readOnly && hybsim.value.dois.toString() === ''">
<span>(Appears when published)</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ <h3 class="text-center">
</div>
</div>
<div class="entity-meta-field">
<div class="entity-meta-label-multi" ng-if="(!$ctrl.readOnly && mission.value.dois.toString() === '') || $ctrl.readOnly">License(s)</div>
<div class="entity-meta-label-multi" ng-if="(!$ctrl.readOnly && experiment.value.dois.toString() === '') || $ctrl.readOnly">License(s)</div>
<div class="entity-meta-data" ng-if="!$ctrl.readOnly && experiment.value.dois.toString() === ''">
<span>(Appears when published)</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class PublishedViewCtrl {
this.browser.project.coordinator_set = this.browser.publication.coordinators;
this.browser.project.simsubstructure_set = this.browser.publication.sim_substructures;
this.browser.project.expsubstructure_set = this.browser.publication.exp_substructures;
this.browser.project.coordinatoroutput_set = this.browser.publication.coordintaor_outputs;
this.browser.project.coordinatoroutput_set = this.browser.publication.coordinator_outputs;
this.browser.project.simoutput_set = this.browser.publication.sim_outputs;
this.browser.project.expoutput_set = this.browser.publication.exp_outputs;
this.browser.project.analysis_set = this.browser.publication.analysiss;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@
<tr class="prj-row" ng-if="$ctrl.project.value.coPis.length && $ctrl.project.value.projectType === 'other' && !$ctrl.readOnly">
<td>Co-PIs</td>
<td class="prj-data">
<span ng-repeat="coPi in $ctrl.authorData.coPis track by $index" ng-if="!$ctrl.loadingUserData.coPis">
<a href="javascript:;" ng-click="$ctrl.showAuthor(coPi)">{{ coPi.lname }}, {{ coPi.fname }}</a><span ng-if="!$last">, </span>
</span>
<ds-user-list usernames="$ctrl.project.value.coPis"></ds-user-list>
</td>
</tr>
<!-- end Co-PI listings -->
Expand Down
4 changes: 4 additions & 0 deletions designsafe/static/styles/ng-designsafe.css
Original file line number Diff line number Diff line change
Expand Up @@ -1043,3 +1043,7 @@ i[class^="icon-ls-pre/post"]:before,
width: 50%;
padding: 10px;
}

.cms-messages {
display: none !important;
}

0 comments on commit c0b9c28

Please sign in to comment.