Ejemplo n.º 1
0
def social_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        return render(request, 'admin/admin_social_accounts.html')
Ejemplo n.º 2
0
def index(request, feedname=None):

    if feedname == None or (
            not FeedUser.objects.filter(username=feedname).exists()):
        return HttpResponseRedirect("/")

    else:

        # Register RSS Visits
        sub = RSSSubscriber.objects.create(request=request,
                                           feedtype=RSSSubscriber.FeedType.web,
                                           feedname=feedname)

        if sub is not None:
            sub.save()

        posts = Post.objects.filter(user=feedname,
                                    activeLink=True).order_by('-id')
        requested_user = FeedUser.objects.get(username=feedname)
        return render(
            request, 'rssviewer.html', {
                'posts': posts,
                'requested_user': requested_user,
                'rss_feed_display': True
            })
Ejemplo n.º 3
0
def contact_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        return render(request, 'admin/admin_contact.html')
Ejemplo n.º 4
0
def add_article_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        return render(request, 'admin/admin_article_form.html')
Ejemplo n.º 5
0
def services_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        request_data = dict()

        if not request.user.is_social_network_activated(network="twitter"):
            request_data[
                "twitter_auth_url"] = TwitterAPI.get_authorization_url(request)
        else:
            request_data[
                "twitter_auth_url"] = False  # False => Don't need to authenticate with Twitter

        if not request.user.is_social_network_activated(network="facebook"):
            request_data[
                "facebook_auth_url"] = FacebookAPI.get_authorization_url()
        else:
            request_data[
                "facebook_auth_url"] = False  # False => Don't need to authenticate with Facebook

        if not request.user.is_social_network_activated(network="linkedin"):
            request_data[
                "linkedin_auth_url"] = LinkedInAPI.get_authorization_url()
        else:
            request_data[
                "linkedin_auth_url"] = False  # False => Don't need to authenticate with LinkedIn

        request_data["slack_auth_url"] = SlackAPI.get_authorization_url()

        return render(request, 'admin/admin_social_sharing.html', request_data)
Ejemplo n.º 6
0
def picture_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        return render(request, 'admin/admin_photo.html')
Ejemplo n.º 7
0
def sub_management(request, feedname=None):
    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        feeds = RSSFeed_Sub.objects.filter(user=feedname,
                                           feed__active=True).order_by("title")
        return render(request, 'admin/admin_sub_listing.html',
                      {'feeds': feeds})
Ejemplo n.º 8
0
def delete_article_listing(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        posts = Post.objects.filter(user=feedname).order_by('-id')
        return render(request, 'admin/admin_post_listing.html',
                      {'posts': posts})
Ejemplo n.º 9
0
def index(request):
    try:
        freemium_period = Option.objects.get(
            parameter="freemium_period").get_bool_value()
    except:
        print("freemium_period may not exists.")
        freemium_period = True

    return render(request, 'home.html', {'free_period': freemium_period})
Ejemplo n.º 10
0
def preferences_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        return render(request, 'admin/admin_preferences.html', {
            "social_networks_enabled":
            request.user.is_social_network_enabled()
        })
Ejemplo n.º 11
0
def personal_info_form(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed

    else:

        country_list = Country.objects.all().order_by('name')
        return render(request, 'admin/admin_personal.html',
                      {'countries': country_list})
Ejemplo n.º 12
0
def index(request, feedname=None):

    check_passed = check_admin(feedname, request.user)

    if check_passed != True:
        return check_passed

    else:
        d = datetime.datetime.now()
        monthtime_elapsed = int(
            round(float(d.day) / monthrange(d.year, d.month)[1] * 100, 0))

        try:
            publication_trend = (
                (float(request.user.get_current_month_post_count()) /
                 request.user.get_last_month_post_count()) - 1) * 100.0

            if publication_trend > 0:
                post_trending = "trending_up"
                post_trending_color = "green-text"
            elif publication_trend < 0:
                post_trending = "trending_down"
                post_trending_color = "red-text"
            else:
                post_trending = "trending_flat"
                post_trending_color = "blue-grey-text"

            publication_trend = int(round(abs(publication_trend), 0))

        except ZeroDivisionError:
            timedelta_registred = datetime.datetime.now(
            ) - request.user.date_joined.replace(tzinfo=None)
            if (timedelta_registred.days < 31):
                publication_trend = -1
                post_trending = "new_releases"
                post_trending_color = "blue-grey-text"
            else:
                publication_trend = 0
                post_trending = "trending_flat"
                post_trending_color = "blue-grey-text"

        data = {
            'monthtime_elapsed': monthtime_elapsed,
            'post_trending': post_trending,
            'publication_trend': publication_trend,
            'post_trending_color': post_trending_color,
        }

        return render(request, 'admin/admin_dashboard.html', data)
Ejemplo n.º 13
0
def modify_article_form(request, feedname=None, postID=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed

    elif postID == None:
        return HttpResponseRedirect("/@" + feedname + "/admin/modify")

    else:
        try:
            post = Post.objects.get(id=postID, user=feedname)
            return render(request, 'admin/admin_article_form.html',
                          {"post": post})

        except:
            return HttpResponseRedirect("/@" + feedname + "/admin/modify")
Ejemplo n.º 14
0
def loginView(request):
    if request.method == 'POST':
        username = request.POST['username'].lower()
        password = request.POST['password']

        user = authenticate(username=username, password=password)

        if user is not None:
            login(request, user)
            return HttpResponseRedirect('/@' + request.user.username +
                                        '/admin')

        else:
            return HttpResponseRedirect('/login/')
    else:
        if request.user.is_authenticated:
            return HttpResponseRedirect('/@' + request.user.username +
                                        '/admin')
        else:
            return render(request, 'login.html', {})
Ejemplo n.º 15
0
def reading_recommendation(request, feedname=None):
    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:

        ###################### Getting the Option Value for the amount of old articles retrieved by RSS Feed ##############################
        try:
            max_recommendations = int(
                Option.objects.get(parameter="max_recommendations").value)
            recommendation_decay = float(60) / max_recommendations

        except ObjectDoesNotExist:
            raise Exception("The Option 'max_recommendations' is not defined")

        #rssarticles = RSSArticle_Assoc.objects.filter(rel_sub_article_assoc__user=request.user, rel_sub_article_assoc__marked_read = False).order_by('-added_date')
        rssarticles = RSSArticle_Assoc.objects.filter(
            user=request.user, marked_read=False).order_by(
                '-article__added_date')[:max_recommendations]

        rssarticles_data = []

        for i, article in enumerate(rssarticles):
            recommendation_score = 97.3 - recommendation_decay * i
            tmp = {
                'id': article.id,
                'short_title': article.short_title(),
                'title': article.title(),
                'rssfeed': article.short_rssfeed(),
                'get_domain': article.short_domain(),
                'link': article.link(),
                'score': recommendation_score,
                'color': int(2.55 * recommendation_score),
                'get_shortdate': article.get_shortdate(),
            }

            rssarticles_data.append(tmp)

        print(len(rssarticles_data))
        return render(request, 'admin/admin_reading_recommendation.html',
                      {'rssarticles': rssarticles_data})
Ejemplo n.º 16
0
def onboarding_view(request, feedname=None):

    check_passed = check_admin(feedname,
                               request.user,
                               bypassOnboardingCheck=True)
    if check_passed != True:
        return check_passed

    else:
        interest_list = Interest.objects.all().order_by('name')
        country_list = Country.objects.all().order_by('name')

        request_data = dict()

        if not request.user.is_social_network_activated(network="twitter"):
            request_data[
                "twitter_auth_url"] = TwitterAPI.get_authorization_url(request)
        else:
            request_data[
                "twitter_auth_url"] = False  # False => Don't need to authenticate with Twitter

        if not request.user.is_social_network_activated(network="facebook"):
            request_data[
                "facebook_auth_url"] = FacebookAPI.get_authorization_url()
        else:
            request_data[
                "facebook_auth_url"] = False  # False => Don't need to authenticate with Facebook

        if not request.user.is_social_network_activated(network="linkedin"):
            request_data[
                "linkedin_auth_url"] = LinkedInAPI.get_authorization_url()
        else:
            request_data[
                "linkedin_auth_url"] = False  # False => Don't need to authenticate with LinkedIn

        request_data["slack_auth_url"] = SlackAPI.get_authorization_url()

        request_data['interests'] = interest_list
        request_data['countries'] = country_list

        return render(request, 'admin/onboarding.html', request_data)
Ejemplo n.º 17
0
def slack_management(request, feedname=None):

    check_passed = check_admin(feedname, request.user)
    if check_passed != True:
        return check_passed
    else:
        request_data = dict()

        slack_teams = dict()

        for team in request.user.rel_slack_integrations.all():
            api_response = SlackAPI(team).get_available_channels()

            if api_response["status"]:
                slack_teams[team.team_name] = api_response["channels"]

        request_data["teams"] = slack_teams
        request_data["slack_auth_url"] = SlackAPI.get_authorization_url()

        return render(request, 'admin/admin_slack_management.html',
                      request_data)
Ejemplo n.º 18
0
def signUPView(request):

    if request.method == 'POST':

        username = request.POST['username'].lower()
        firstname = request.POST['firstname']
        lastname = request.POST['lastname']
        email = request.POST['email']
        gender = request.POST['gender']
        country = request.POST['country']
        password = request.POST['password']
        birthdate = request.POST['birthdate']

        tmp_usr = FeedUser.objects.create_user(username,
                                               email,
                                               password,
                                               firstname=firstname,
                                               lastname=lastname,
                                               country=country,
                                               gender=gender,
                                               birthdate=birthdate)

        user = authenticate(username=username, password=password)
        login(request, user)

        # We create an associated token for the user
        Token.objects.create(user=user)

        return HttpResponseRedirect('/@' + request.user.username + '/admin')

    else:

        if request.user.is_authenticated:
            return HttpResponseRedirect('/@' + request.user.username +
                                        '/admin')
        else:
            country_list = Country.objects.all().order_by('name')
            return render(request, 'signup.html', {'countries': country_list})
Ejemplo n.º 19
0
def terms(request):
    return render(request, 'terms.html', {})
Ejemplo n.º 20
0
def about(request):
    return render(request, 'about.html', {})
Ejemplo n.º 21
0
def contact(request):
    return render(request, 'contact.html', {})
Ejemplo n.º 22
0
def faq(request):
    return render(request, 'faq.html', {})