Beispiel #1
0
    def setUp(self):
        # Uses the cookie hack from:
        # https://stackoverflow.com/questions/22494583/login-with-code-when-using-liveservertestcase-with-django
        client = Client()
        self.user = get_user_model().objects.create_user('a', 'b', 'c')
        client.login(username='******', password='******')
        self.cookie = client.cookies['sessionid']
        self.selenium.get("{}{}".format(self.live_server_url, "/"))
        self.selenium.add_cookie({
            'name': 'sessionid',
            'value': self.cookie.value,
            'secure': False,
            'path': '/'
        })
        self.selenium.refresh()

        self.short = "asdf"
        self.project = Project(creator=self.user,
                               name="long_asdf",
                               name_short=self.short)
        self.project.save()
        self.project.developer.set((self.user.pk, ))
        self.project.manager.set((self.user.pk, ))
        self.project.save()

        si = SlackIntegration()
        si.project = self.project
        si.api_token = "foo"
        si.channel = "channel"
        si.save()

        self.title_name = 'This is title'
        self.comment = "This is comment"
Beispiel #2
0
 def get_redirect_url(self, *args, **kwargs):
     if not SLACK_ID:
         return reverse("project:edit",
                        kwargs={'project': self.kwargs['project']})
     slack = SlackClient("")
     code = self.request.GET['code']
     resp = slack.api_call(
         "oauth.access",
         code=code,
         client_id=SLACK_ID,
         client_secret=SLACK_SECRET,
         redirect_uri="https://" + HOST +
         reverse("integration:slack:auth",
                 kwargs={'project': self.kwargs['project']}),
     )
     if resp['ok']:
         si = SlackIntegration()
         si.api_token = resp['access_token']
         si.project = Project.objects.get(name_short=self.kwargs['project'])
         si.save()
         return reverse("integration:slack:update",
                        kwargs={
                            'project': self.kwargs['project'],
                            'pk': si.pk
                        })
     return reverse("project:edit",
                    kwargs={'project': self.kwargs['project']})