forked from noahpresler/semesterly
-
Notifications
You must be signed in to change notification settings - Fork 62
Tracks feature usage and notifies users of new features they haven't tried yet #1264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
spencerckhuang
wants to merge
1
commit into
jhuopensource:develop
Choose a base branch
from
spencerckhuang:feature/new-feature-highlighting
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Copyright (C) 2017 Semester.ly Technologies, LLC | ||
| # | ||
| # Semester.ly is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Semester.ly is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Copyright (C) 2017 Semester.ly Technologies, LLC | ||
| # | ||
| # Semester.ly is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Semester.ly is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
|
|
||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Copyright (C) 2017 Semester.ly Technologies, LLC | ||
| # | ||
| # Semester.ly is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Semester.ly is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
|
|
||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class FeatureUseTrackerConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'feature_use_tracker' |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Copyright (C) 2017 Semester.ly Technologies, LLC | ||
| # | ||
| # Semester.ly is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Semester.ly is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
|
|
||
| from django.db import models | ||
| from django.contrib.auth.models import User | ||
| from django.utils.translation import gettext_lazy as _ | ||
|
|
||
| class Feature(models.TextChoices): | ||
| COMPARE_TIMETABLES = "CT", _("Compare Timetables") | ||
| SIS_ADD_TO_CART = "SATC", _("SIS Add To Cart") | ||
| SCREENSHOT = "SS", _("Screenshot") | ||
| CUSTOM_EVENT = "CE", _("Custom Event") | ||
| DRAG_SEARCH = "DS", _("Custom Event") | ||
| EXPORT_TIMETABLE_TO_CALENDAR = "ETTC", _("Export Timetable to Calendar") | ||
| FRIENDS = "F", _("Friends") | ||
| ADVANCED_SEARCH = "AS", _("Advanced Search") | ||
| COURSE_OPTIMIZER = "CO", _("Course Optimizer") | ||
|
|
||
|
|
||
| class FeatureUse(models.Model): | ||
| """Database object containing indicators which provide information about whether | ||
| a User has used a certain feature or not | ||
| """ | ||
| user = models.OneToOneField(User, on_delete=models.deletion.CASCADE) | ||
| feature_name = models.CharField(max_length=4, choices=Feature) | ||
| time_used = models.DateTimeField(auto_now_add=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from rest_framework import serializers | ||
| from .models import FeatureUse | ||
|
|
||
| class FeatureUseSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = FeatureUse | ||
| fields = ["id", "user", "feature_name", "time_used"] | ||
| read_only_fields = ["time_used"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Copyright (C) 2017 Semester.ly Technologies, LLC | ||
| # | ||
| # Semester.ly is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Semester.ly is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
|
|
||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from django.urls import re_path | ||
| from .views import FeatureUseView, csrf_cookie_view | ||
|
|
||
| urlpatterns = [ | ||
| re_path(r"^feature_use/csrf/$", csrf_cookie_view, name="feature_use_get_csrf"), | ||
| re_path(r"^feature_use/$", FeatureUseView.as_view(), name="feature_use"), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright (C) 2017 Semester.ly Technologies, LLC | ||
| # | ||
| # Semester.ly is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Semester.ly is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
|
|
||
| from rest_framework.views import APIView | ||
| from rest_framework.response import Response | ||
| from feature_use_tracker.models import FeatureUse, Feature | ||
| from feature_use_tracker.serializers import FeatureUseSerializer | ||
|
|
||
|
|
||
| # Create your views here. | ||
| class FeatureUseView(APIView): | ||
| """ | ||
| List relevant feature use entries (for red-dot rendering logic), or create a new entry | ||
| """ | ||
|
|
||
| def post(self, request): | ||
| # drop the 'user' field if client supplies it (we only want to get User through inference) | ||
| data = request.data.copy() | ||
| data.pop("user", None) | ||
|
|
||
| feature = data.get("feature_name") | ||
|
|
||
| # delete duplicates if necessary | ||
| exists = FeatureUse.objects.filter(user=request.user, feature_name=feature).exists() | ||
| if exists: | ||
| return Response(status=204) | ||
|
|
||
| serializer = FeatureUseSerializer(data=data) | ||
| serializer.is_valid(raise_exception=True) | ||
| serializer.save(user=request.user) | ||
| return Response(serializer.data) | ||
|
|
||
|
|
||
| def get(self, request): | ||
| rows = FeatureUse.objects.filter(user=request.user) | ||
| serializer = FeatureUseSerializer(rows, many=True) | ||
| return Response(serializer.data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more?