Skip to content
This repository was archived by the owner on Sep 12, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions submit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .models import configure_sql, create_schema, populate_database
from .security import get_user, group_finder

__version__ = '1.2.0'
__version__ = '1.0.3'


class Root(object):
Expand Down Expand Up @@ -79,7 +79,7 @@ def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
configure_sql(engine)

secure_cookies = settings.get('secure_cookies') != 'false'
secure_cookies = True
if 'pyramid_debugtoolbar' in settings['pyramid.includes']:
create_schema(global_config['__file__'])
populate_database()
Expand Down
16 changes: 5 additions & 11 deletions submit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ class UmailAddress(EmailAddress):

"""A validator to verify that a umail address is correct."""

def run(self, value, errors, request, *args):
retval = super(UmailAddress, self).run(value.lower(), errors, request,
*args)
def run(self, value, errors, *args):
retval = super(UmailAddress, self).run(value.lower(), errors, *args)
if errors:
return retval
if not retval.endswith('@umail.ucsb.edu'):
self.add_error(errors, 'must end with @umail.ucsb.edu')
return retval
# Fetch name
try:
name = fetch_name_by_umail(retval, request)
name = fetch_name_by_umail(retval)
except Exception as exc:
self.add_error(errors, exc.message)
return retval
Expand Down Expand Up @@ -274,21 +273,16 @@ def fetch_request_ids(item_ids, cls, attr_name, verification_list=None):
return items


def fetch_name_by_umail(umail, request):
def fetch_name_by_umail(umail):
def extract(item):
if len(data[item]) == 1:
return data[item][0]
raise Exception('Multiple values returned: {}'.format(data))

uid = umail.split('@')[0]

# Return the portion before @umail.ucsb.edu if ldap_uri is not provided
ldap_uri = request.registry.settings.get('ldap_uri')
if not ldap_uri:
return uid

# connect to ldap
ldap_conn = ldap.initialize(ldap_uri)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is code added by Bryce to assist with running, for example, on AWS, outside of the context where the UCSB ldap server is directly accessible.

ldap_conn = ldap.initialize('ldaps://directory.ucsb.edu')
ldap_conn.protocol_version = ldap.VERSION3
results = ldap_conn.search_s(
'o=ucsb', ldap.SCOPE_ONELEVEL, filterstr='uid={}'.format(uid),
Expand Down
2 changes: 1 addition & 1 deletion submit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class Project(BasicBase, Base):
makefile = relationship(File, backref='makefile_for_projects')
makefile_id = Column(Integer, ForeignKey('file.id'), nullable=True)
name = Column(Unicode, nullable=False)
status = Column(Enum('locked', 'notready', 'ready', name='proj_status'),
status = Column(Enum('locked', 'notready', 'ready', name='status'),
nullable=False, server_default='notready')
submissions = relationship('Submission', backref='project',
cascade='all, delete-orphan')
Expand Down
4 changes: 4 additions & 0 deletions submit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,10 @@ def submission_view(request, submission, as_user):
else:
prev_group = next_group = None


Copy link
Contributor Author

@pconrad pconrad Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad hack added by P. Conrad for the CS8 Summer 2017 lab exam.

It is ok if it gets reverted. The purpose was so that students in earlier sections could not share their answers to the lab exam questions with students in later sections. That is, if the first four characters of the project are the magic value "EXAM", then all non admin users are prevented from seeing the "download" link on the view of the submission.

if not submission_admin and submission.project.name[0:4]=="EXAM":
files = {}

return {'diff_table': diff_table,
'extra_files': extra_files,
'files': files,
Expand Down