Skip to content

Commit

Permalink
Merge pull request #1154 from UniversityRadioYork/rens-updates
Browse files Browse the repository at this point in the history
Adding Nickname's to users and fixing some wordings on user profile to be line with gdpr
  • Loading branch information
hitime1234 authored Aug 26, 2024
2 parents 2a756b8 + 40bd095 commit e2a7cc8
Show file tree
Hide file tree
Showing 21 changed files with 260 additions and 62 deletions.
122 changes: 90 additions & 32 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ The codespace includes Mailhog, which will trap any emails sent by MyRadio. To s
click the Local Address next to port 8025 in the Ports panel.

## Docker Install

If you have Docker on your system, use Docker Compose to set up an environment.
Simply run `docker compose up -d`, and visit "https://localhost:4443/myradio/".
Simply run `docker compose up -d` and visit "https://localhost:4443/myradio/".

If you encounter an error with autoload.php:
find the id of your myradio container using `docker dontainer ls`
enter a bash session with `docker exec -it [myradioid] bash`
then in this session run `composer install`
finally exit the session by running `exit`

## Vagrant Install

MyRadio comes with a Vagrantfile based on Ubuntu 19.10.
If you have [Vagrant](https://www.vagrantup.com) installed and want to get
developing or playing right away, just run `vagrant up` and a few minutes
Expand All @@ -43,8 +51,9 @@ so be sure to never run this in a production environment, or remove the
permission before doing so.

## Uncontained Install

Install Apache2, PHP, Composer and PostgreSQL on your prefered Unix-based distro.
Or Windows, if you're into that.
Or Windows, if you're into that.
MyRadio has been tested with Ubuntu and FreeBSD.

cd to your MyRadio installation and run `composer install`
Expand Down Expand Up @@ -74,6 +83,7 @@ Alias /api /usr/local/www/MyRadio/src/PublicAPI
Restart Apache2, go to http://hostname/myradio

To make a new postgresql server, run the following after:

```
pg_createcluster [YOUR_POSTGRES_VERSION] myradio
su postgres
Expand All @@ -85,36 +95,47 @@ CREATE DATABASE myradio WITH OWNER=myradio;
# Post-Installation

## Myradio Setup

CONNECT:
- Open up "https://localhost:4443/myradio/" in a browser
- [Use Chrome as this often fails to run on Firefox]
- It will say "connection not private" so press "advanced" and then "proceed"

- Open up "https://localhost:4443/myradio/" in a browser
- [Use Chrome as this often fails to run on Firefox]
- It will say "connection not private" so press "advanced" and then "proceed"

DATABASE:
- On the intro screen press "Click here to continue"
- Enter the database details (see Default Credentials) and press Next
- Press "run task", wait a few seconds and then press "run task" again.
- [This method is a workaround for a slight bug in how we build the database]


- On the intro screen press "Click here to continue"
- Enter the database details (see Default Credentials) and press Next
- Press "run task", wait a few seconds and then press "run task" again.
- [This method is a workaround for a slight bug in how we build the database]

USER:
- [Here you can make config changes but the defaults are autofilled]
- Press "complete starting set", scroll and press "save and continue"
- Input any first and last name, an email (NOT an @york.ac.uk email) and a password
- [If you enter an @york.ac.uk email you will not be able to login at all]
- Login using the email and password you just enterted

- [Here you can make config changes but the defaults are autofilled]
- Press "complete starting set", scroll and press "save and continue"
- Input any first and last name, an email (NOT an @york.ac.uk email) and a password
- [If you enter an @york.ac.uk email you will not be able to login at all]
- Login using the email and password you just enterted

- If you encounter an error you need to create the file /var/www/myradio/src/MyRadio_Config.local.php with the text from the "Show Config" button
- [if you are using docker this needs to be done within the docker container using `docker exec -it [myradioid] bash`]

## Default Credentials

Database: (when building the database, these credentials are needed)
- Hostname: `postgres` if running in Docker, `localhost` otherwise
- Database: myradio
- Username: myradio
- Password: myradio

- Hostname: `postgres` if running in Docker, `localhost` otherwise
- Database: myradio
- Username: myradio
- Password: myradio

Vagrant VM: (if you need to ssh into the virtual machine)
- Username: vagrant
- Password: vagrant

- Username: vagrant
- Password: vagrant

## Tests

MyRadio uses [Codeception](http://codeception.com/quickstart) for its test suite.

[This was written with a Vagrant install in mind - has not been tested on Docker]
Expand All @@ -132,28 +153,65 @@ blanks the `myradio_test` database each time it is ran, so it can be used to
reset the database and config file, should this prove necessary.

Summary:
* `composer install`
* `vagrant up`
* `vagrant ssh -- /vagrant/scripts/reset-db.sh`
* `src/vendor/bin/codecept run`

- `composer install`
- `vagrant up`
- `vagrant ssh -- /vagrant/scripts/reset-db.sh`
- `src/vendor/bin/codecept run`

The vagrant initialisation script also runs `composer install`, but that is run
on the virtual machine which also installs the PHP extensions required for
Codeception. These extensions may be missing locally, so running composer will
confirm that they are present.

## Next Steps

Once you've got through the setup wizard, the next thing that's most useful to
you is most likely creating a show.

To do this, you first need to:
- Create a Term (Show Scheduler -> Manage Terms)
- Create a Show (List My Shows -> Create a Show)
- Apply for a Season of your new Show (List My Shows -> New Season)
- Schedule the Season (Shows Scheduler)

- Create a Term (Show Scheduler -> Manage Terms)
- Create a Show (List My Shows -> Create a Show)
- Apply for a Season of your new Show (List My Shows -> New Season)
- Schedule the Season (Shows Scheduler)

### Setting up your own 2016-site

First pull [2016-site](https://github.com/UniversityRadioYork/2016-site)

#### database

Next you need a api_key to allow the website to access myradio's show information,

login into database with details used during setup of myradio

`INSERT INTO myury.api_key (key_string, description) VALUES ('ARANDOMSTRINGOFCHARACTERS', '2016-site development api key');`

`INSERT INTO myury.api_key_auth (key_string, typeid) VALUES ('ARANDOMSTRINGOFCHARACTERS', (SELECT typeid FROM l_action WHERE phpconstant = 'AUTH_APISUDO'));`

[please choose a better key than 'ARANDOMSTRINGOFCHARACTERS']

You might need add some other database columns to create shows

for example:

- explict podcasts (to create shows)
- selector (expected by 2016-site/can remove this from models/index.go 2016-site)

2016-site uses parts of database that aren't made on myradio creation,

#### finishing steps

This will fix shows not loading on 2016-site when using the base myradio database

After completing all these setups:

you can use setup guide in [2016-site](https://github.com/UniversityRadioYork/2016-site),
And setup a reverse proxy to "https://localhost:4443/api/v2" or configure ssl for https connections
To complete the setup.

### A note on Seasons and Terms
MyRadio splits Shows into "Seasons". Any Season is applied to in relation to a
"Term", which is a 10-week space of time. This is because The University of
York has 10 week terms, if you didn't know.

MyRadio splits Shows into "Seasons". Any Season is applied to in relation to a
"Term", which is a user defined space of time (normally 11-15 weeks). This is because The University of York has 12 week semesters, if you didn't know.
2 changes: 2 additions & 0 deletions schema/api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type User implements Node & MyRadioObject {
id: ID! @bind(method: "getID")
itemId: Int! @bind(method: "getID")
fname: String! @bind(method: "getFName")
nname: String! @bind(method: "getNName")
sname: String! @bind(method: "getSName")

# Public information
Expand Down Expand Up @@ -393,6 +394,7 @@ type EmailDestination {
type MemberSearchResult {
memberid: Int!
fname: String!
nname: String!
sname: String!
eduroam: String
local_alias: String
Expand Down
3 changes: 3 additions & 0 deletions schema/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@
"fname": {
"type": "string"
},
"nname": {
"type": "string"
},
"sname": {
"type": "string"
},
Expand Down
3 changes: 2 additions & 1 deletion schema/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ CREATE TABLE mail_list (
COMMENT ON TABLE mail_list IS 'Definitions of mailing lists';
COMMENT ON COLUMN mail_list.listid IS 'Surrogate Key';
COMMENT ON COLUMN mail_list.listname IS 'Name of the list';
COMMENT ON COLUMN mail_list.defn IS 'A SQL string that returns fname, sname and email address.';
COMMENT ON COLUMN mail_list.defn IS 'A SQL string that returns fname, nname ,sname and email address.';
COMMENT ON COLUMN mail_list.toexim IS 'Whether to create a mail alias on the email server for this list.';
COMMENT ON COLUMN mail_list.listaddress IS 'If the list is exported, this is the list''s email address.';
COMMENT ON COLUMN mail_list.subscribable IS 'Whether members can (un)subscribe freely.';
Expand All @@ -1276,6 +1276,7 @@ COMMENT ON TABLE mail_subscription IS 'If a list is subscribable, then all membe
CREATE TABLE member (
memberid integer DEFAULT nextval(('"member_memberid_seq"'::text)::regclass) NOT NULL,
fname character varying(255) NOT NULL,
nname character varying(255),
sname character varying(255) NOT NULL,
college integer NOT NULL,
phone character varying(255),
Expand Down
5 changes: 5 additions & 0 deletions schema/patches/19.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE member
ADD COLUMN nname character varying(255);

INSERT INTO metadata.metadata_key VALUES (20,'upload_starttime',false,'In the case where a manual upload is required (because an event started late) will need to start late. This is a UTC time.',300,false);
INSERT INTO metadata.metadata_key VALUES (21,'upload_endtime',false,'In the case where a manual upload is required (because an event started late) will need to finish early/late.',300,false);
2 changes: 1 addition & 1 deletion scripts/gdprdeleteuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
try{
$db->query(
'INSERT INTO public.member(
memberid, fname, sname, college, receive_email, data_removal)
memberid, fname, nname, sname, college, receive_email, data_removal)
VALUES ($1, \'deleted\', \'user\', 10, false, \'deleted\')',
[$deletedUserId]
);
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/MyRadio/MyRadioNews.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function getNewsItem($newsentryid, MyRadio_User $user = null)
$db = Database::getInstance();

$news = $db->fetchOne(
'SELECT newsentryid, fname || \' \' || sname AS author, timestamp AS posted, content
'SELECT newsentryid, fname || \' \' || sname AS author, fname || \' "\' || nname || \'" \' || sname as nickname, timestamp AS posted, content
FROM public.news_feed, public.member
WHERE newsentryid=$1
AND news_feed.memberid = member.memberid',
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ServiceAPI/MyRadio_Season.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static function create($params = [])
* Select an appropriate value for $term_id.
*/
$term_id = MyRadio_Term::getActiveApplicationTerm()->getID();
$num_weeks = MyRadio_Term::getActiveApplicationTerm()->getTermWeeks();
$num_weeks = MyRadio_Term::getActiveApplicationTerm()->getTermWeeks();

//Start a transaction
self::$db->query('BEGIN');
Expand Down
6 changes: 5 additions & 1 deletion src/Classes/ServiceAPI/MyRadio_Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,11 @@ public function reportExplicit()

$title = htmlspecialchars($this->getTitle());
$artist = htmlspecialchars($this->getArtist());
$userName = htmlspecialchars($currentUser->getFName() . ' ' . $currentUser->getSName());
if (empty($currentUser->getNName()) == True) {
$userName = htmlspecialchars($currentUser->getFName() . ' ' . $currentUser->getSName());
} else {
$userName = htmlspecialchars($currentUser->getFName() . ' "' . $currentUser->getNName() . '" ' . $currentUser->getSName());
}
$editUrl = URLUtils::makeURL('Library', 'editTrack', ['trackid' => $this->getID()]);
MyRadioEmail::sendEmailToList(
MyRadio_List::getByName('playlisting'),
Expand Down
Loading

0 comments on commit e2a7cc8

Please sign in to comment.