Commit 0ae3765e authored by Nik Khlestov's avatar Nik Khlestov

Added logic to view and edit notification frequency.

parent 272441b8
Pipeline #17677 passed with stage
in 40 seconds
......@@ -47,7 +47,8 @@ To verify it've successfully created, or just to see a list of your projects run
uptr project list
Output is tab-separated lines of name, id, and a flag to mark a project is pinned.
#### Pinning a project
##### Pinning a project
Given in most cases you'll have a tracking project per programming project, to minimize arguments required to operate packages, you can set a default project for some directory:
uptr project pin --project-id <project id>
......@@ -55,6 +56,20 @@ uptr project pin --project-id <project id>
You can get project id from the second column of `uptr project list` output.
To check if pinning was succesful, you can look at projects list.
##### Notifications management
Every time a global package version is updated, and your version is less then global version, we send you a mail notification.
Next, we will send notifications according to your notification preferences, which are set per project:
uptr project notifications --count 2 --delay 2 --project-id 18
Here, this means you'll have 2 notifications (after default one) sent with 2 days delay.
If you have a pinned project, you can omit `--project-id` option.
If you will not provide any of `count` or `delay` parameters, you'll see a message like:
You are notified 2 times with 3 days delay.
Which shows your current settings. Also, it's shown after an update.
### Packages management
First of all, all packages exist in the scope of a project. In case you don't have a pinned project, or want to use not default one, you have to provide its id as:
......@@ -8,7 +8,7 @@ def readme():
description='Command line interface for update tracker.',
import click
import sys
import yaml
from click import MissingParameter
from .main import settings, session, PROJECT_CONFIG_FILE
......@@ -46,4 +47,35 @@ def list():
'%s\t%s\t%s' % (p['name'], p['id'], is_pinned_mark)
\ No newline at end of file
@click.option('--count', '-c', type=int, required=False)
@click.option('--delay-days', '-d', type=int, required=False)
@click.option('--project-id', '-p', type=int, required=False)
def notifications(count, delay_days, project_id):
"""Set notification frequency/count for project."""
current_project_id = project_id or settings.project_id
if not current_project_id:
# Emulation of required parameter with possibility of pinning.
raise MissingParameter(param_hint=['--project-id', '-p'], param_type='option',
message='Please provide it or pin the project.')
url = f'{settings.address}/api/projects/{current_project_id}/notifications/'
if count or delay_days:
# here's an update action
req = {}
if count:
req['notification_count'] = count
if delay_days:
req['notification_delay_days'] = delay_days
resp = session.patch(url, data=req)
resp = session.get(url)
data = resp.json()
click.echo('You are notified {times} times with {days} days delay.'.format(
......@@ -57,7 +57,6 @@ def login(email, password):
'password': password
data = resp.json()
# save token to USER_CONFIG_FILE
with open(USER_CONFIG_FILE, 'r') as ifile:
conf = yaml.load( or {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment