Example #1
0
    def customize_citations(self):

        # Obtain the parameters.
        show_journal_str = request.params['toggle_journal']
        show_authors_str = request.params['toggle_authors']
        show_keywords_str = request.params['toggle_keywords']

        # Obtain the User object (as opposed to the auth.User object).
        cur_user = controller_globals._get_user_from_email(request.environ.get('repoze.who.identity')['user'].email)

        # Make changes to the booleans of the user object.
        cur_user.show_journal = {"Show":True, "Hide":False}[show_journal_str]
        cur_user.show_authors = {"Show":True, "Hide":False}[show_authors_str]
        cur_user.show_keywords = {"Show":True, "Hide":False}[show_keywords_str]

        # Add the changes to the database.
        Session.commit()

        # These messages appear in their designated separate locations,
        #   i.e. on the top left corner of the div that corresponds to this function.
        # This is more appropriate than having a general message on some part of the screen.
        c.account_msg = ""
        c.account_msg_citation_settings = "Citation Settings changes have been applied."

        return render("/accounts/account.mako")
Example #2
0
 def reset_password(self):
     user_email = request.params['email']
     user_for_email = controller_globals._get_user_from_email(user_email)
     if user_for_email:
         token = self.gen_token_to_reset_pwd(user_for_email)
         message = """
                     Hi, %s. \n
                     Someone (hopefully you!) asked to reset your abstrackr password.
                     To do so, follow this link:\n
                     \t %saccount/confirm_password_reset/%s.\n
                     Note that your password will be temporarily changed if you follow this link!
                     If you didn't request to reset your password, just ignore this email.
                   """ % (user_for_email.fullname, url(
             '/', qualified=True), token)
         print token
         self.send_email_to_user(user_for_email,
                                 "resetting your abstrackr password",
                                 message)
         c.pwd_msg = "OK -- check your email (and your spam folder!)"
         return render('/accounts/recover.mako')
     else:
         c.pwd_msg = """
             Well, this is awkward.
             We don't have a user in our database with email: %s.
             Try again?""" % user_email
         return render('/accounts/recover.mako')
Example #3
0
    def customize_citations(self):

        # Obtain the parameters.
        show_journal_str = request.params['toggle_journal']
        show_authors_str = request.params['toggle_authors']
        show_keywords_str = request.params['toggle_keywords']

        # Obtain the User object (as opposed to the auth.User object).
        cur_user = controller_globals._get_user_from_email(
            request.environ.get('repoze.who.identity')['user'].email)

        # Make changes to the booleans of the user object.
        cur_user.show_journal = {"Show": True, "Hide": False}[show_journal_str]
        cur_user.show_authors = {"Show": True, "Hide": False}[show_authors_str]
        cur_user.show_keywords = {
            "Show": True,
            "Hide": False
        }[show_keywords_str]

        # Add the changes to the database.
        Session.commit()

        # These messages appear in their designated separate locations,
        #   i.e. on the top left corner of the div that corresponds to this function.
        # This is more appropriate than having a general message on some part of the screen.
        c.account_msg = ""
        c.account_msg_citation_settings = "Citation Settings changes have been applied."

        return render("/accounts/account.mako")
Example #4
0
    def my_projects(self):
        person = request.environ.get('repoze.who.identity')['user']
        c.person = person

        # Get user object from db.
        user = controller_globals._get_user_from_email(person.email)

        # Set user's show preference defaults in case they weren't set.
        if (user.show_journal == True or user.show_journal == False):
            c.show_journal = user.show_journal
        else:
            user.show_journal = True

        if (user.show_authors == True or user.show_authors == False):
            c.show_authors = user.show_authors
        else:
            user.show_authors = True

        if (user.show_keywords == True or user.show_keywords == False):
            c.show_keywords = user.show_keywords
        else:
            user.show_keywords = True

        project_q = Session.query(model.Project)
        c.leading_projects = user.leader_of_projects
        leading_project_ids = [proj.id for proj in c.leading_projects]

        c.participating_projects = [
            p for p in user.member_of_projects
            if p.id not in leading_project_ids
        ]

        c.review_ids_to_names_d = self._get_review_ids_to_names_d(
            c.participating_projects)

        statuses_q = Session.query(model.PredictionsStatus)
        c.statuses = {}

        c.do_we_have_a_maybe = {}
        for project_id in leading_project_ids:

            predictions_for_review = statuses_q.filter(
                model.PredictionsStatus.project_id == project_id).all()
            if len(predictions_for_review
                   ) > 0 and predictions_for_review[0].predictions_exist:
                c.statuses[project_id] = True
            else:
                c.statuses[project_id] = False

            c.do_we_have_a_maybe[project_id] = False

        # Flag projects that have locked priorities
        c.projects_w_locked_priorities = self._get_projects_w_locked_priorities(
            leading_project_ids)

        c.my_work = False
        c.my_projects = True

        return render('/accounts/dashboard.mako')
Example #5
0
    def show_merge_review_screen(self):
        person = request.environ.get('repoze.who.identity')['user']
        c.person = person
        user = controller_globals._get_user_from_email(person.email)

        projects_person_leads = self._get_projects_person_leads(user)
        c.reviews = projects_person_leads

        return render('/reviews/merge_reviews.mako')
Example #6
0
    def show_merge_review_screen(self):
        person = request.environ.get('repoze.who.identity')['user']
        c.person = person
        user = controller_globals._get_user_from_email(person.email)

        projects_person_leads = self._get_projects_person_leads(user)
        c.reviews = projects_person_leads

        return render('/reviews/merge_reviews.mako')
Example #7
0
    def my_projects(self):
        person = request.environ.get('repoze.who.identity')['user']
        c.person = person

        # Get user object from db.
        user = controller_globals._get_user_from_email(person.email)

        # Set user's show preference defaults in case they weren't set.
        if (user.show_journal==True or user.show_journal==False):
            c.show_journal = user.show_journal
        else:
            user.show_journal = True

        if (user.show_authors==True or user.show_authors==False):
            c.show_authors = user.show_authors
        else:
            user.show_authors = True

        if (user.show_keywords==True or user.show_keywords==False):
            c.show_keywords = user.show_keywords
        else:
            user.show_keywords = True

        project_q = Session.query(model.Project)
        c.leading_projects = user.leader_of_projects
        leading_project_ids = [proj.id for proj in c.leading_projects]

        c.participating_projects = [p for p in user.member_of_projects if p.id not in leading_project_ids]

        c.review_ids_to_names_d = self._get_review_ids_to_names_d(c.participating_projects)

        statuses_q = Session.query(model.PredictionsStatus)
        c.statuses = {}

        c.do_we_have_a_maybe = {}
        for project_id in leading_project_ids:

            predictions_for_review = statuses_q.filter(model.PredictionsStatus.project_id==project_id).all()
            if len(predictions_for_review) > 0 and predictions_for_review[0].predictions_exist:
                c.statuses[project_id] = True
            else:
                c.statuses[project_id] = False

            c.do_we_have_a_maybe[project_id] = False

        # Flag projects that have locked priorities
        c.projects_w_locked_priorities = self._get_projects_w_locked_priorities(leading_project_ids)

        c.my_work = False
        c.my_projects = True

        return render('/accounts/dashboard.mako')
Example #8
0
 def confirm_password_reset(self, id):
     token = str(id)
     reset_pwd_q = Session.query(model.ResetPassword)
     # we pull all in case they've tried to reset their pwd a few times
     # by the way, these should time-expire...
     matches = reset_pwd_q.filter(model.ResetPassword.token == token).all()
     if len(matches) == 0:
         return """
             Hrmm... It looks like you're trying to reset your password, but I can't match the provided token.
             Please go back to the email that was sent to you and make sure you've copied the URL correctly.
             """
     user = controller_globals._get_user_from_email(matches[0].user_email)
     for match in matches:
         Session.delete(match)
     user._set_password(token)
     Session.commit()
     return '''
       ok! your password has been set to %s (you can change it once you've logged in).\n
       <a href="%s">log in here</a>.''' % (token, url('/', qualified=True))
Example #9
0
 def confirm_password_reset(self, id):
     token = str(id)
     reset_pwd_q = Session.query(model.ResetPassword)
     # we pull all in case they've tried to reset their pwd a few times
     # by the way, these should time-expire...
     matches = reset_pwd_q.filter(model.ResetPassword.token == token).all()
     if len(matches) == 0:
         return """
             Hrmm... It looks like you're trying to reset your password, but I can't match the provided token.
             Please go back to the email that was sent to you and make sure you've copied the URL correctly.
             """
     user = controller_globals._get_user_from_email(matches[0].user_email)
     for match in matches:
         Session.delete(match)
     user._set_password(token)
     Session.commit()
     return '''
       ok! your password has been set to %s (you can change it once you've logged in).\n
       <a href="%s">log in here</a>.''' % (token, url('/', qualified=True))
Example #10
0
 def reset_password(self):
     user_email = request.params['email']
     user_for_email = controller_globals._get_user_from_email(user_email)
     if user_for_email:
         token = self.gen_token_to_reset_pwd(user_for_email)
         message = """
                     Hi, %s. \n
                     Someone (hopefully you!) asked to reset your abstrackr password.
                     To do so, follow this link:\n
                     \t %saccount/confirm_password_reset/%s.\n
                     Note that your password will be temporarily changed if you follow this link!
                     If you didn't request to reset your password, just ignore this email.
                   """ % (user_for_email.fullname, url('/', qualified=True), token)
         print token
         self.send_email_to_user(user_for_email, "resetting your abstrackr password", message)
         c.pwd_msg = "OK -- check your email (and your spam folder!)"
         return render('/accounts/recover.mako')
     else:
         c.pwd_msg = """
             Well, this is awkward.
             We don't have a user in our database with email: %s.
             Try again?""" % user_email
         return render('/accounts/recover.mako')
Example #11
0
    def my_work(self):
        person = request.environ.get('repoze.who.identity')['user']
        c.person = person
        user = controller_globals._get_user_from_email(c.person.email)
        if not user:
            log.error('''\
Hum...fetching user from the database returned False.
We need to investigate. Go remove the catch all in
controller_globals.py, method _get_user_from_email()
to see which OperationalError is being raised ''')

        # If somehow the user's citation settings variables don't get initialized yet,
        # then the following 3 if-else blocks should take care of it in order to avoid
        # any errors due to the values of the variables being null:
        c.show_journal = user.show_journal if not user.show_journal is None else True

        if (user.show_authors==True or user.show_authors==False):
            c.show_authors = user.show_authors
        else:
            user.show_authors = True

        if (user.show_keywords==True or user.show_keywords==False):
            c.show_keywords = user.show_keywords
        else:
            user.show_keywords = True


        # pull all assignments for this person
        assignment_q = Session.query(model.Assignment)
        all_assignments = assignment_q.filter(model.Assignment.user_id == person.id).all()

        # This process is incredibly slow. Take it out for now and find out
        # why the .done and .done_so_far field on assignment is off sometimes.
        #self._set_assignment_done_status(all_assignments)

        self._clear_this_user_locks(all_assignments)

        # Build assignment completion status dictionary
        c.d_completion_status = self._get_assignment_completion_status(all_assignments)

        c.outstanding_assignments = [a for a in all_assignments if not a.done]
        # if there's an initial assignment, we'll only show that.
        assignment_types = [assignment.assignment_type for assignment in \
                                                    c.outstanding_assignments]

        #####
        # for any review that has an initial assignment, we will show
        # *only* that assignment, thereby forcining participants to
        # finish initial assignments before moving on to other
        # assignments. fix for issue #5.
        ####
        # which reviews have (outstanding) initial assigments?
        reviews_with_initial_assignments = []
        for assignment in c.outstanding_assignments:
            if assignment.assignment_type == "initial":
                reviews_with_initial_assignments.append(assignment.project_id)


        # now remove other (non-initial) assignments for reviews
        # that have an initial assignment
        filtered_assignments = [assignment for assignment in c.outstanding_assignments if \
                                assignment.project_id not in reviews_with_initial_assignments or \
                                assignment.assignment_type == "initial"]

        c.outstanding_assignments = filtered_assignments

        c.finished_assignments = [a for a in all_assignments if a.done]


        project_q = Session.query(model.Project)
        c.participating_projects = user.member_of_projects
        c.review_ids_to_names_d = self._get_review_ids_to_names_d(c.participating_projects)

        c.my_work = True
        c.my_projects = False
        return render('/accounts/dashboard.mako')
Example #12
0
    def my_work(self):
        person = request.environ.get('repoze.who.identity')['user']
        c.person = person
        user = controller_globals._get_user_from_email(c.person.email)
        if not user:
            log.error('''\
Hum...fetching user from the database returned False.
We need to investigate. Go remove the catch all in
controller_globals.py, method _get_user_from_email()
to see which OperationalError is being raised ''')

        # If somehow the user's citation settings variables don't get initialized yet,
        # then the following 3 if-else blocks should take care of it in order to avoid
        # any errors due to the values of the variables being null:
        c.show_journal = user.show_journal if not user.show_journal is None else True

        if (user.show_authors == True or user.show_authors == False):
            c.show_authors = user.show_authors
        else:
            user.show_authors = True

        if (user.show_keywords == True or user.show_keywords == False):
            c.show_keywords = user.show_keywords
        else:
            user.show_keywords = True

        # pull all assignments for this person
        assignment_q = Session.query(model.Assignment)
        all_assignments = assignment_q.filter(
            model.Assignment.user_id == person.id).all()

        # This process is incredibly slow. Take it out for now and find out
        # why the .done and .done_so_far field on assignment is off sometimes.
        #self._set_assignment_done_status(all_assignments)

        self._clear_this_user_locks(all_assignments)

        # Build assignment completion status dictionary
        c.d_completion_status = self._get_assignment_completion_status(
            all_assignments)

        c.outstanding_assignments = [a for a in all_assignments if not a.done]
        # if there's an initial assignment, we'll only show that.
        assignment_types = [assignment.assignment_type for assignment in \
                                                    c.outstanding_assignments]

        #####
        # for any review that has an initial assignment, we will show
        # *only* that assignment, thereby forcining participants to
        # finish initial assignments before moving on to other
        # assignments. fix for issue #5.
        ####
        # which reviews have (outstanding) initial assigments?
        reviews_with_initial_assignments = []
        for assignment in c.outstanding_assignments:
            if assignment.assignment_type == "initial":
                reviews_with_initial_assignments.append(assignment.project_id)

        # now remove other (non-initial) assignments for reviews
        # that have an initial assignment
        filtered_assignments = [assignment for assignment in c.outstanding_assignments if \
                                assignment.project_id not in reviews_with_initial_assignments or \
                                assignment.assignment_type == "initial"]

        c.outstanding_assignments = filtered_assignments

        c.finished_assignments = [a for a in all_assignments if a.done]

        project_q = Session.query(model.Project)
        c.participating_projects = user.member_of_projects
        c.review_ids_to_names_d = self._get_review_ids_to_names_d(
            c.participating_projects)

        c.my_work = True
        c.my_projects = False
        return render('/accounts/dashboard.mako')