Ejemplo n.º 1
0
    def reset_connection(self, callback_host=""):
        """ Generate a new link to authorize access to given dropbox. Will invalidate the old connection.
            callback_url will be passed with dropbox auth link so after authorization you are redirected.
        """

        # request new session, request new auth key
        (app_key, app_secret, access_type) = self.get_dropbox_app_keys()
        sess = session.DropboxSession(app_key, app_secret, access_type)
        request_token = sess.obtain_request_token()

        # visit this url to validate
        url = sess.build_authorize_url(request_token)

        finalize_url = reverse("django_dropbox.views.finalize_connection", kwargs={"dropbox_folder_id": self.id})

        if callback_host == "":
            msg = (
                request_token,
                'Please visit <a href="'
                + url
                + '" target="_new"> this link</a>  to authorize access to dropbox.\
                                  After authorizing, click <a href="'
                + finalize_url
                + '">this link</a>',
            )
        else:
            url = url + "&oauth_callback=" + callback_host + finalize_url
            msg = (request_token, 'Please visit <a href="' + url + '"> this link</a> to authorize access to dropbox.')

        return msg
Ejemplo n.º 2
0
 def get_submission_URL(self):
     """ What url can you go to to submit for this project? """
     URL = reverse('comicsite.views.site', args=[self.short_name])
     if self.submission_page_name:
         if self.submission_page_name.startswith("http://") or self.submission_page_name.startswith("https://"):
             # the url in the submission page box is a full url
             return self.submission_page_name
         else:
             page = self.submission_page_name
             if not page.endswith("/"):
                 page += "/"
             URL += page
     return URL
Ejemplo n.º 3
0
    def to_projectlink(self):
        """ Return a ProjectLink representation of this comicsite, to show in an
        overview page listing all projects

        """

        thumb_image_url = reverse("project_serve_file", args=[self.short_name, self.logo])

        args = {
            "abreviation": self.short_name,
            "title": self.short_name,
            "description": self.description,
            "URL": reverse("comicsite.views.site", args=[self.short_name]),
            "download URL": "",
            "submission URL": self.get_submission_URL(),
            "event name": self.event_name,
            "year": "",
            "event URL": self.event_url,
            "image URL": self.logo,
            "thumb_image_url": thumb_image_url,
            "website section": "active challenges",
            "overview article url": self.publication_url,
            "overview article journal": self.publication_journal_name,
            "overview article citations": "",
            "overview article date": "",
            "submission deadline": "",
            "workshop date": self.workshop_date,
            "open for submission": "yes" if self.is_open_for_submissions else "no",
            "data download": "yes" if self.offers_data_download else "no",
            "dataset downloads": self.number_of_downloads,
            "registered teams": "",
            "submitted results": self.number_of_submissions,
            "last submission date": self.last_submission_date,
            "hosted on comic": True,
            "created at": self.created_at,
        }

        projectlink = ProjectLink(args)
        return projectlink
Ejemplo n.º 4
0
    def get_absolute_url(self):
        """ With this method, admin will show a 'view on site' button """

        url = reverse('comicsite.views.page', args=[self.comicsite.short_name,self.title])
        return url
Ejemplo n.º 5
0
    def get_absolute_url(self):
        """ With this method, admin will show a 'view on site' button """

        url = reverse("comicsite.views.site", args=[self.short_name])
        return url