Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
d1a4d70
First steps in adding the notes moddel and updating the api
mathildepm Jan 9, 2021
0fbc433
packages updated, but site doesn't display
shaynak Jan 11, 2021
aaeac9d
notes try a message box
mathildepm Jan 11, 2021
b19179a
advisor view migrations
shaynak Jan 11, 2021
f096966
up to delegate
shaynak Jan 11, 2021
301a502
updating our front end
mathildepm Jan 11, 2021
1623324
Merge branch 'stage' of https://github.com/bmun/huxley into stage
mathildepm Jan 11, 2021
6a6c5f8
formatted
shaynak Jan 11, 2021
a5807ae
more changes to js files
mathildepm Jan 11, 2021
c4136ea
resolved merge conflicts
mathildepm Jan 11, 2021
9b91789
resolved merge conflicts for real this time
mathildepm Jan 11, 2021
81edf5e
update history
shaynak Jan 12, 2021
c8e0bde
React.PropTypes changed to PropTypes
mathildepm Jan 12, 2021
005023f
npm run build works
shaynak Jan 12, 2021
55f11d3
resolving some merge conflicts :(
mathildepm Jan 12, 2021
0ff6db4
remove default exports from views
shaynak Jan 12, 2021
7437fad
remove default export actions
shaynak Jan 12, 2021
503874c
Updating exports
mathildepm Jan 12, 2021
9420e62
update utils to remove export default
shaynak Jan 12, 2021
c46d41f
more export changes
mathildepm Jan 12, 2021
65ce3bf
fix history, remove contexts, etc.
shaynak Jan 12, 2021
8667b6b
function changes
mathildepm Jan 12, 2021
c1bd5dd
changes to react functions and some print statements to be removed later
mathildepm Jan 15, 2021
90863d9
updated react files
mathildepm Jan 18, 2021
4b71da6
some more changes to react, major changes to Huxley.js and entry.js
mathildepm Jan 18, 2021
0992db4
yay things are working - changed router to browserrouter
mathildepm Jan 18, 2021
5c991f3
adding entry
mathildepm Jan 18, 2021
b3c6dc0
prettier + moved functions to arrow functions
shaynak Jan 18, 2021
f47e1fe
fix shaker
shaynak Jan 18, 2021
7860336
travis test changed
mathildepm Jan 19, 2021
dc15fab
updated other functions
shaynak Jan 19, 2021
55685a6
delegatepaperview changes
mathildepm Jan 19, 2021
b850bcb
Merge branch 'stage' of https://github.com/bmun/huxley into stage
mathildepm Jan 19, 2021
013a932
some export changes, as well as link changes
mathildepm Jan 21, 2021
c71ccc4
delegate deletion issue resolved
mathildepm Jan 21, 2021
8aa9d60
merged stage with updates into notes
mathildepm Jan 21, 2021
b1b621c
zoom links tab for advisors
mathildepm Jan 21, 2021
c31f6b2
note additions
mathildepm Jan 21, 2021
169b128
import button
mathildepm Jan 22, 2021
d355222
fixed registration register
mathildepm Jan 22, 2021
4a45d95
Merge branch 'stage' of https://github.com/bmun/huxley into notes
mathildepm Jan 22, 2021
0959b5a
delegates sheets integration
shaynak Jan 29, 2021
52e2bce
updated all views that have download options to include sheet options
shaynak Jan 29, 2021
932a30c
fix markdown links
shaynak Jan 31, 2021
6ad1220
reorganizing note components
mathildepm Feb 1, 2021
4c4507b
Merge branch 'stage' of https://github.com/bmun/huxley into zoom-links
mathildepm Feb 1, 2021
3b8894b
newline + add to default local settings
shaynak Feb 2, 2021
9147ba7
delegate zoom links
mathildepm Feb 4, 2021
8167241
changes to NoteStore
mathildepm Feb 4, 2021
34c0671
Advisor Waiver view updated
mathildepm Feb 8, 2021
f84abae
fixed merge conflicts
mathildepm Feb 8, 2021
a5be1da
updates to notes view -- switch messages to time retrieval vs. conver…
shaynak Feb 10, 2021
f8b0c34
sidebar added
mathildepm Feb 11, 2021
ade2073
polling works + sidebar sorts
shaynak Feb 11, 2021
49d5185
add title to message box and address all runtime js errors
shaynak Feb 11, 2021
f2e7592
remove relative sizing
shaynak Feb 11, 2021
34739a2
filter sidebar and get rid of datalist
shaynak Feb 12, 2021
61e0774
more robust flow typing and other small changes
shaynak Feb 12, 2021
f8e0c68
more flow updates
shaynak Feb 13, 2021
f45126f
updated tests
shaynak Feb 14, 2021
580e82b
resolved all js errors
shaynak Feb 14, 2021
1fc9465
Chair Note Views
mathildepm Feb 18, 2021
f1f1e81
updates
shaynak Feb 18, 2021
0a86312
more css
shaynak Feb 18, 2021
80cf2ab
feed ui much better
shaynak Feb 18, 2021
5fc2485
red flagged messages
shaynak Feb 18, 2021
308ec16
scrolling things
shaynak Feb 18, 2021
59d68cb
added filter bar to top of feed view
shaynak Feb 22, 2021
c530ee3
toggle notes on and off
shaynak Feb 23, 2021
43eb91a
notes may be ready! Added extra features for notes on off
mathildepm Feb 23, 2021
3be0e59
Merge branch 'notes' into stage
mathildepm Feb 23, 2021
877b7c6
Merge branch 'stage' of https://github.com/bmun/huxley into sheets
shaynak Feb 23, 2021
c0d98af
Added waiver confirmations
shaynak Feb 23, 2021
3ed7462
Update committee permissions tests and fix Travis
shaynak Feb 23, 2021
9f5cfdf
Fixed tests that were broken locally
shaynak Feb 24, 2021
282daa0
Add refresh button to notes.
shaynak Feb 24, 2021
d4bbbc8
blacklisting
mathildepm Feb 25, 2021
80e4a91
changed text for disabled
mathildepm Feb 25, 2021
3a2e039
added blacklists
mathildepm Feb 25, 2021
ccdb3b0
Filter assignments visible in notes view by whether delegate exists'
shaynak Feb 25, 2021
7eee5bb
Merge branch 'notes' of https://github.com/bmun/huxley into notes
shaynak Feb 25, 2021
2296cb4
merged notes into zoom links
mathildepm Feb 25, 2021
6979004
Added words to flag messages on
shaynak Feb 25, 2021
e2c9aa4
Added words to flag messages on
shaynak Feb 25, 2021
8133262
Temporarily comment out money spent field from committee feedback view
shaynak Feb 25, 2021
29a3b79
Merge branch 'notes' of https://github.com/bmun/huxley into notes
shaynak Feb 25, 2021
43a32e8
updated text for zoom links
mathildepm Feb 25, 2021
1405e57
Merge branch 'notes' into zoom-links
mathildepm Feb 25, 2021
f0eb260
Fix committee and delegate tests
shaynak Feb 25, 2021
5fcfa0a
Merge pull request #730 from bmun/sheets
shaynak Feb 25, 2021
a47a6ad
Clear sheets prior to updating
shaynak Feb 25, 2021
427abd5
update note permission
shaynak Feb 25, 2021
6bf56f4
Try to fix migrations
shaynak Feb 25, 2021
0e2585f
Try to fix migrations
shaynak Feb 25, 2021
44d604e
Merge branch 'stage' of https://github.com/bmun/huxley into stage
shaynak Feb 25, 2021
2b93444
Ensure conference notes being off doesn't allow anyone to send notes
shaynak Feb 25, 2021
3772d34
edits to delegate view and blacklisted words
mathildepm Feb 25, 2021
3327e47
Merge pull request #739 from bmun/stage
mathildepm Feb 25, 2021
466b6b8
Bump pillow from 6.2.1 to 7.1.0
dependabot[bot] Feb 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[ignore]

[include]

[libs]

[lints]

[options]
module.system.node.allow_root_relative=true
module.system.node.root_relative_dirname=./huxley/www/js

[strict]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ test_position_paper.doc

env/
.vscode/

huxley/service.json
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ python:
- "3.6"
install:
- pip install -r requirements.txt
- nvm install 6.4
- nvm use 6.4
- nvm install 12.19.0
- nvm use 12.19.0
- npm install
before_script:
- python manage.py migrate
script:
- python manage.py test
- npm test
- npm run flow
2 changes: 1 addition & 1 deletion docs/tutorials/setup/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var TodoApp = React.createClass({
}
});

module.exports = TodoApp;
export default TodoApp;
```

Then in www.html change the line `<p>Hello, world!</p>` to `<div id="main"></div>`
Expand Down
47 changes: 43 additions & 4 deletions huxley/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def has_permission(self, request, view):
return (
user_is_advisor(request, view, assignment.registration.school_id)
or user_is_chair(request, view, assignment.committee_id) or
user_is_delegate(request, view, assignment_id, 'assignment'))
user_is_delegate(request, view, assignment_id, 'assignment') or
user_is_in_committee(request, view, assignment.committee_id))


class AssignmentListPermission(permissions.BasePermission):
Expand All @@ -132,10 +133,31 @@ def has_permission(self, request, view):
school_id = request.query_params.get('school_id', -1)
committee_id = request.query_params.get('committee_id', -1)
return (user_is_chair(request, view, committee_id) or
user_is_advisor(request, view, school_id))
user_is_advisor(request, view, school_id) or
user_is_in_committee(request, view, committee_id))

return False

class CommitteeDetailPermission(permissions.BasePermission):
'''Accept requests to retrieve a committee from any user.
Only allow superusers and chairs to update committees.'''

def has_permission(self, request, view):
if request.user.is_superuser:
return True

committee_id = view.kwargs.get('pk', None)
committee = Committee.objects.get(id=committee_id)
user = request.user
method = request.method

if method != 'GET':
return user_is_chair(request, view,
committee_id)

return True



class DelegateDetailPermission(permissions.BasePermission):
'''Accept requests to retrieve, update, and destroy a delegate from the
Expand Down Expand Up @@ -185,7 +207,8 @@ def has_permission(self, request, view):
school_id = request.query_params.get('school_id', -1)
committee_id = request.query_params.get('committee_id', -1)
return (user_is_chair(request, view, committee_id) or
user_is_advisor(request, view, school_id))
user_is_advisor(request, view, school_id) or
user_is_delegate(request, view, committee_id, 'committee'))

if method == 'POST':
return user_is_advisor(request, view, request.data['school'])
Expand Down Expand Up @@ -331,6 +354,14 @@ def has_permission(self, request, view):

return False

class NotePermission(permissions.BasePermission):
'''Accept requests to view Notes when user is not an advisor'''
def has_permission(self, request, view):
user = request.user
if user.is_authenticated and not user.is_advisor():
return True
return False


def user_is_advisor(request, view, school_id):
user = request.user
Expand All @@ -351,7 +382,15 @@ def user_is_delegate(request, view, target_id, field=None):
if not user.is_authenticated or not user.is_delegate():
return False

if field:
if field and field != 'committee':
return getattr(user.delegate, field + '_id', -1) == int(target_id)
elif field == 'committee':
return getattr(getattr(user.delegate, 'assignment', -1), 'committee_id', -1) == int(target_id)

return user.delegate_id == int(target_id)

def user_is_in_committee(request, view, committee_id):
user = request.user
if not user.is_authenticated or not user.is_delegate() or not user.delegate:
return False
return user.delegate.assignment.committee_id == int(committee_id)
1 change: 1 addition & 0 deletions huxley/api/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
from .position_paper import PositionPaperSerializer
from .rubric import RubricSerializer
from .secretariat_member import SecretariatMemberSerializer
from .note import NoteSerializer
4 changes: 3 additions & 1 deletion huxley/api/serializers/committee.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ class Meta:
'full_name',
'delegation_size',
'rubric',
'special', )
'special',
'zoom_link',
'notes_activated')
16 changes: 16 additions & 0 deletions huxley/api/serializers/note.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2011-2020 Berkeley Model United Nations. All rights reserved.
# Use of this source code is governed by a BSD License (see LICENSE).

from rest_framework import serializers

from huxley.core.models import Note

class TimestampField(serializers.ReadOnlyField):
def to_representation(self, value):
return value.timestamp.timestamp()

class NoteSerializer(serializers.ModelSerializer):
timestamp = TimestampField(source='*')
class Meta:
model = Note
fields = ('id', 'is_chair', 'sender', 'recipient', 'msg', 'timestamp')
158 changes: 125 additions & 33 deletions huxley/api/tests/test_committee.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2011-2015 Berkeley Model United Nations. All rights reserved.
# Use of this source code is governed by a BSD License (see LICENSE).

from huxley.accounts.models import User
from huxley.api import tests
from huxley.api.tests import auto
from huxley.utils.test import models
Expand All @@ -22,57 +22,141 @@ class CommitteeDetailPutTestCase(tests.UpdateAPITestCase):
params = {'name': 'DISC', 'special': True}

def setUp(self):
self.committee = models.new_committee()
self.chair = models.new_user(username='chair',
password='chair',
user_type=User.TYPE_CHAIR)
self.committee = models.new_committee(user=self.chair)

def test_anonymous_user(self):
'''Unauthenticated users shouldn't be able to update committees.'''
response = self.get_response(self.committee.id, params=self.params)
self.assertMethodNotAllowed(response, 'PUT')
self.assertNotAuthenticated(response)

def test_authenticated_user(self):
'''Authenticated users shouldn't be able to update committees.'''
models.new_user(username='user', password='user')
self.client.login(username='user', password='user')
def test_delegate(self):
'''Delegates shouldn't be able to update committees.'''
models.new_user(username='delegate',
password='user',
user_type=User.TYPE_DELEGATE)
self.client.login(username='delegate', password='user')

response = self.get_response(self.committee.id, params=self.params)
self.assertPermissionDenied(response)

def test_advisor(self):
'''Advisors shouldn't be able to update committees.'''
models.new_user(username='advisor',
password='user',
user_type=User.TYPE_ADVISOR)
self.client.login(username='advisor', password='user')

response = self.get_response(self.committee.id, params=self.params)
self.assertPermissionDenied(response)

def test_chair(self):
'''Chairs should be able to update committees.'''
self.client.login(username='chair', password='chair')

response = self.get_response(self.committee.id, params=self.params)
self.assertMethodNotAllowed(response, 'PUT')
response.data.pop('rubric')
self.assertEqual(
response.data, {
'id': self.committee.id,
'name': 'DISC',
'full_name': self.committee.full_name,
'delegation_size': self.committee.delegation_size,
'special': True,
'notes_activated': self.committee.notes_activated,
'zoom_link': self.committee.zoom_link
})

def test_superuser(self):
'''Superusers shouldn't be able to update committees.'''
models.new_superuser(username='user', password='user')
self.client.login(username='user', password='user')

response = self.get_response(self.committee.id, params=self.params)
self.assertMethodNotAllowed(response, 'PUT')
response.data.pop('rubric')
self.assertEqual(
response.data, {
'id': self.committee.id,
'name': 'DISC',
'full_name': self.committee.full_name,
'delegation_size': self.committee.delegation_size,
'special': True,
'notes_activated': self.committee.notes_activated,
'zoom_link': self.committee.zoom_link
})


class CommitteeDetailPatchTestCase(tests.PartialUpdateAPITestCase):
url_name = 'api:committee_detail'
params = {'name': 'DISC', 'special': True}

def setUp(self):
self.committee = models.new_committee()
self.chair = models.new_user(username='chair',
password='chair',
user_type=User.TYPE_CHAIR)
self.committee = models.new_committee(user=self.chair)

def test_anonymous_user(self):
'''Unauthenticated users shouldn't be able to update committees.'''
response = self.get_response(self.committee.id, params=self.params)
self.assertMethodNotAllowed(response, 'PATCH')
self.assertNotAuthenticated(response)

def test_authenticated_user(self):
'''Authenticated users shouldn't be able to update committees.'''
models.new_user(username='user', password='user')
self.client.login(username='user', password='user')
def test_delegate(self):
'''Delegates shouldn't be able to update committees.'''
models.new_user(username='delegate',
password='user',
user_type=User.TYPE_DELEGATE)
self.client.login(username='delegate', password='user')

response = self.get_response(self.committee.id, params=self.params)
self.assertPermissionDenied(response)

def test_advisor(self):
'''Advisors shouldn't be able to update committees.'''
models.new_user(username='advisor',
password='user',
user_type=User.TYPE_ADVISOR)
self.client.login(username='advisor', password='user')

response = self.get_response(self.committee.id, params=self.params)
self.assertPermissionDenied(response)

def test_chair(self):
'''Chairs should be able to update committees.'''
self.client.login(username='chair', password='chair')

response = self.get_response(self.committee.id, params=self.params)
self.assertMethodNotAllowed(response, 'PATCH')
response.data.pop('rubric')
self.assertEqual(
response.data, {
'id': self.committee.id,
'name': 'DISC',
'full_name': self.committee.full_name,
'delegation_size': self.committee.delegation_size,
'special': True,
'notes_activated': self.committee.notes_activated,
'zoom_link': self.committee.zoom_link
})

def test_superuser(self):
'''Superusers shouldn't be able to update committees.'''
models.new_superuser(username='user', password='user')
self.client.login(username='user', password='user')

response = self.get_response(self.committee.id, params=self.params)
self.assertMethodNotAllowed(response, 'PATCH')
response.data.pop('rubric')
self.assertEqual(
response.data, {
'id': self.committee.id,
'name': 'DISC',
'full_name': self.committee.full_name,
'delegation_size': self.committee.delegation_size,
'special': True,
'notes_activated': self.committee.notes_activated,
'zoom_link': self.committee.zoom_link
})


class CommitteeDetailDeleteTestCase(auto.DestroyAPIAutoTestCase):
Expand All @@ -84,12 +168,12 @@ def get_test_object(cls):

def test_anonymous_user(self):
'''Anonymous users cannot delete committees.'''
self.do_test(expected_error=auto.EXP_DELETE_NOT_ALLOWED)
self.do_test(expected_error=auto.EXP_NOT_AUTHENTICATED)

def test_authenticated_user(self):
'''Authenticated users cannot delete committees.'''
self.as_default_user().do_test(
expected_error=auto.EXP_DELETE_NOT_ALLOWED)
expected_error=auto.EXP_PERMISSION_DENIED)

def test_superuser(self):
'''Superusers cannot delete committees.'''
Expand All @@ -107,24 +191,32 @@ def test_anonymous_user(self):
response = self.get_response()
for r in response.data:
r.pop('rubric')
self.assertEqual(response.data, [
{'delegation_size': c1.delegation_size,
'special': c1.special,
'id': c1.id,
'full_name': c1.full_name,
'name': c1.name}, {'delegation_size': c2.delegation_size,
'special': c2.special,
'id': c2.id,
'full_name': c2.full_name,
'name': c2.name}
])
self.assertEqual(response.data, [{
'delegation_size': c1.delegation_size,
'special': c1.special,
'id': c1.id,
'full_name': c1.full_name,
'name': c1.name,
'notes_activated': c1.notes_activated,
'zoom_link': c1.zoom_link
}, {
'delegation_size': c2.delegation_size,
'special': c2.special,
'id': c2.id,
'full_name': c2.full_name,
'name': c2.name,
'notes_activated': c2.notes_activated,
'zoom_link': c2.zoom_link
}])


class CommitteeListPostTestCase(tests.CreateAPITestCase):
url_name = 'api:committee_list'
params = {'name': 'DISC',
'full_name': 'Disarmament and International Security',
'delegation_size': 100}
params = {
'name': 'DISC',
'full_name': 'Disarmament and International Security',
'delegation_size': 100
}

def test_anonymous_user(self):
'''Unauthenticated users shouldn't be able to create committees.'''
Expand Down
Loading